#include <bits/stdc++.h>
using namespace std;
long long n;
void solve() {
  cin >> n;
  long long ocount = 0, ecount = 0;
  long long mineve = LONG_LONG_MAX, minodd = LONG_LONG_MAX;
  vector<long long> oarr, earr;
  for (long long i = 0; i <= n - 1; i++) {
    long long temp;
    cin >> temp;
    if (temp % 2 == 0) {
      earr.push_back(temp);
    }
    if (temp % 2 == 1) {
      oarr.push_back(temp);
    }
  }
  sort(oarr.begin(), oarr.end());
  sort(earr.begin(), earr.end());
  if (oarr.size() == earr.size() + 1 || earr.size() == oarr.size() + 1 ||
      oarr.size() == earr.size()) {
    cout << 0 << '\n';
    return;
  }
  long long ans = 0;
  if (oarr.size() > earr.size()) {
    for (long long i = 1; i <= oarr.size() - earr.size() - 1; i++) {
      ans += oarr[i - 1];
    }
  } else {
    for (long long i = 1; i <= earr.size() - oarr.size() - 1; i++) {
      ans += earr[i - 1];
    }
  }
  cout << max(ans, ans);
}
int main() {
  ios::sync_with_stdio(false);
  solve();
}
