#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long ara[2005], n, sum, jur, bejur;
vector<int> even, odd;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ara[i];
    if (ara[i] & 1) {
      odd.push_back(ara[i]);
      bejur++;
    } else {
      even.push_back(ara[i]);
      jur++;
    }
    sum += ara[i];
  }
  if (jur == bejur) {
    cout << "0\n";
    exit(0);
  }
  if (abs(jur - bejur) == 1) {
    cout << "0\n";
    exit(0);
  }
  long long mn = min(jur, bejur);
  if (odd.size() > 0) sort(odd.rbegin(), odd.rend());
  if (even.size() > 0) sort(even.rbegin(), even.rend());
  if (mn > 0) {
    for (int i = 0; i < mn; i++) {
      sum -= odd[i];
      sum -= even[i];
    }
    if (odd[mn] > even[mn]) {
      sum -= odd[mn];
    } else {
      sum -= even[mn];
    }
  } else {
    if (jur > bejur) {
      sum -= even[0];
    } else {
      sum -= odd[0];
    }
  }
  cout << sum << "\n";
  return 0;
}
