#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, num;
  cin >> n;
  vector<long long> o, e;
  for (long long i = 0; i < n; i++) {
    cin >> num;
    if (num & 1)
      o.push_back(num);
    else
      e.push_back(num);
  }
  if (o.size()) sort(o.begin(), o.end());
  if (e.size()) sort(e.begin(), e.end());
  long long oo = 0, ee = 0, idx, mi = 0;
  if (o.size() > e.size()) {
    idx = o.size() - e.size();
    for (long long i = 0; i < idx - 1; i++) mi += o[i];
  } else {
    idx = e.size() - o.size();
    for (long long i = 0; i < idx - 1; i++) mi += e[i];
  }
  cout << mi;
}
