#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2 != 0) {
      ans = (ans * a) % 1000000007;
    }
    a = ((a % 1000000007) * (a % 1000000007)) % 1000000007;
    b >>= 1;
  }
  return ans;
}
void sieve(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p]) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++) {
    if (prime[p]) cout << p << " ";
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    long long n, z;
    cin >> n;
    std::vector<long long> odd, even;
    for (long long i = 0; i < n; i++) {
      cin >> z;
      if (z % 2 == 0)
        even.push_back(z);
      else
        odd.push_back(z);
    }
    sort(odd.begin(), odd.end(), greater<long long>());
    sort(even.begin(), even.end(), greater<long long>());
    long long s = 0;
    int i = 0, j = 0;
    while (i < even.size() && j < odd.size()) {
      i++;
      j++;
    }
    i++;
    j++;
    while (i < even.size()) {
      s += even[i];
      i++;
    }
    while (j < odd.size()) {
      s += odd[j];
      j++;
    }
    cout << s;
  }
  return 0;
}
