#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int odd = 0, even = 0;
  vector<int> o, e;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] & 1) {
      odd++;
      o.push_back(a[i]);
    } else {
      even++;
      e.push_back(a[i]);
    }
  }
  if (abs(even - odd) <= 1) {
    cout << 0 << endl;
    return 0;
  }
  if (even > odd) {
    int req = even - odd - 1;
    sort(e.begin(), e.end());
    int ans = 0;
    for (int i = 0; i < req; i++) ans += e[i];
    cout << ans << endl;
  } else {
    int req = odd - even - 1;
    sort(o.begin(), o.end());
    int ans = 0;
    for (int i = 0; i < req; i++) ans += o[i];
    cout << ans << endl;
  }
  return 0;
}
