#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n + 5], od = 0, ev = 0, x = 0, y = 0, o[n + 4], e[n + 4], sm = 0,
                      i;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      e[x++] = a[i];
      ev++;
    } else {
      o[y++] = a[i];
      od++;
    }
  }
  sort(e, e + x, greater<long long>());
  sort(o, o + y, greater<long long>());
  if (abs(od - ev) <= 1) {
    cout << "0";
    return 0;
  }
  long long k = min(od, ev);
  if (od > ev) {
    for (i = k + 1; i < y; ++i) {
      sm += o[i];
    }
  } else {
    for (i = k + 1; i < x; ++i) {
      sm += e[i];
    }
  }
  cout << sm;
}
