#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long odd = 0, even = 0;
  long long a[30000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] & 1)
      odd++;
    else
      even++;
  }
  sort(a, a + n);
  int diff = abs(even - odd);
  if (diff <= 1)
    cout << "0" << endl;
  else {
    long long sum = 0;
    diff--;
    bool want = false;
    if (even > odd) want = true;
    for (int i = 0; i < n; i++) {
      if (diff > 0) {
        if (want) {
          if (a[i] % 2 == 0) sum += a[i], diff--;
        } else {
          if (a[i] & 1) sum += a[i], diff--;
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
