#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int countSetBits(int n) {
  unsigned int count = 0;
  while (n) {
    n &= (n - 1);
    count++;
  }
  return count;
}
int powerOfTwo(int n) { return n && (!(n & (n - 1))); }
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  sort(a.rbegin(), a.rend());
  vector<long long int> o;
  vector<long long int> e;
  long long int even = 0;
  long long int odd = 0;
  for (long long int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      even++;
      e.push_back(a[i]);
    } else {
      odd++;
      o.push_back(a[i]);
    }
  }
  long long int sum = 0;
  if (even > odd) {
    for (long long int i = odd + 1; i < even; i++) sum = sum + e[i];
  } else if (odd > even) {
    for (long long int i = even + 1; i < odd; i++) sum = sum + o[i];
  }
  cout << sum;
}
int main() {
  solve();
  return 0;
}
