#include <bits/stdc++.h>
using namespace std;
long long mod_exp(long long x, long long y, long long mm) {
  if (y == 0)
    return (1);
  else if (y % 2 == 0)
    return (mod_exp((x * x) % mm, y / 2, mm));
  else
    return ((x * mod_exp((x * x) % mm, (y - 1) / 2, mm)) % mm);
}
void subset_sum(long long x[], long long n, set<long long>& z) {
  long long t = 1 << n, sum;
  for (long long i = 0; i < t; i++) {
    sum = 0;
    for (long long j = 0; j < n; j++) {
      if (i & (1 << j)) sum += x[j];
    }
    z.insert(sum);
  }
}
int main() {
  long long sum, n, z;
  cin >> n;
  vector<long long> o, e;
  for (long long i = 0; i < n; i++) {
    cin >> z;
    if (z % 2 == 0)
      e.push_back(z);
    else
      o.push_back(z);
  }
  sort(e.begin(), e.end());
  sort(o.begin(), o.end());
  if (e.size() > o.size()) {
    reverse(e.begin(), e.end());
    sum = accumulate(o.begin(), o.end(), 0);
    for (long long i = 0; i < o.size() + 1; i++) sum = sum + e[i];
  } else if (e.size() < o.size()) {
    reverse(o.begin(), o.end());
    sum = accumulate(e.begin(), e.end(), 0);
    for (long long i = 0; i < e.size() + 1; i++) sum = sum + o[i];
  } else
    sum = accumulate(e.begin(), e.end(), 0) + accumulate(o.begin(), o.end(), 0);
  cout << accumulate(e.begin(), e.end(), 0) +
              accumulate(o.begin(), o.end(), 0) - sum;
  return 0;
}
