#include <bits/stdc++.h>
using namespace std;
long long n, a[2005], b[2005], na, nb, s, x;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x % 2 == 0) {
      na++;
      a[na] = x;
    } else {
      nb++;
      b[nb] = x;
    }
  }
  if (abs(na - nb) <= 1) {
    cout << 0;
    return 0;
  }
  if (na > nb) {
    sort(a + 1, a + na + 1);
    for (int i = nb + 2; i <= na; i++) {
      s += a[i];
    }
    cout << s;
  } else {
    sort(b + 1, b + nb + 1);
    for (int i = na + 2; i <= nb; i++) {
      s += b[i];
    }
    cout << s;
  }
  return 0;
}
