#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ods;
  vector<int> evs;
  int ev = 0, od = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] % 2 == 0) {
      ev++;
      evs.push_back(a[i]);
    } else {
      od++;
      ods.push_back(a[i]);
    }
  }
  if (abs(ev - od) <= 1) {
    cout << 0;
    return 0;
  }
  sort(evs.rbegin(), evs.rend());
  sort(ods.rbegin(), ods.rend());
  if (evs > ods) {
    int l = 0;
    while (l != ods.size()) {
      sum -= ods[l];
      sum -= evs[l];
      l++;
    }
    sum -= evs[l];
    cout << sum;
  } else {
    int l = 0;
    while (l != evs.size()) {
      sum -= ods[l];
      sum -= evs[l];
      l++;
    }
    sum -= ods[l];
    cout << sum;
  }
}
