#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  vector<int> b;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x & 1) {
      a.push_back(x);
    } else {
      b.push_back(x);
    }
  }
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  int aa = a.size();
  int bb = b.size();
  int ans = 0;
  if (aa <= bb) {
    for (int i = aa + 1; i <= bb - 1; i++) {
      ans += b[i];
    }
  } else {
    for (int i = bb + 1; i <= aa - 1; i++) {
      ans += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
