#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sumo = 0, sume = 0;
  cin >> n;
  vector<int> e, o;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 1) {
      o.push_back(x);
      sumo += x;
    } else {
      e.push_back(x);
      sume += x;
    }
  }
  sort(o.begin(), o.end());
  reverse(o.begin(), o.end());
  sort(e.begin(), e.end());
  reverse(e.begin(), e.end());
  int odd = o.size();
  int even = e.size();
  int ans = 0, tp = 0, ct = 0;
  int de = min(odd, even) + 1;
  for (int i = 0; i < de; i++) {
    if (i < odd) {
      tp += o[i];
    }
    if (i < even) {
      ct += e[i];
    }
  }
  if (tp > ct) {
    ans = (sume - ct) + (sumo - tp);
  } else {
    ans = (sumo - tp) + (sume - ct);
  }
  cout << max(0, ans) << "\n";
  return 0;
}
