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