#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a, b;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    if (x % 2 == 0)
      a.push_back(x);
    else
      b.push_back(x);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int l = (int)a.size() - 1;
  int r = (int)b.size() - 1;
  int now;
  if ((int)a.size() > (int)b.size())
    now = 0;
  else
    now = 1;
  while (l >= 0 && r >= 0) {
    if (now == 1)
      r--;
    else
      l--;
  }
  if ((int)a.size() > (int)b.size())
    l--;
  else if ((int)a.size() < (int)b.size())
    r--;
  long long sum = 0;
  if ((int)a.size() > (int)b.size()) {
    for (int i = 0; i <= l; i++) sum += a[i];
  } else {
    for (int i = 0; i <= r; i++) sum += b[i];
  }
  cout << sum;
  return 0;
}
