#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, o = 1, e = 1;
  long long sum = 0;
  int odd[2005], even[2005];
  memset(odd, 0, sizeof(odd));
  memset(even, 0, sizeof(even));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x % 2 == 0) {
      odd[o++] = x;
    } else {
      even[e++] = x;
    }
  }
  if (o == e || (abs(o - e)) == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(odd + 1, odd + o);
  sort(even + 1, even + e);
  if (o > e) {
    for (int i = 1; i <= o - e - 1; i++) sum += odd[i];
  } else {
    for (int i = 1; i <= e - o - 1; i++) sum += even[i];
  }
  cout << sum << endl;
  return 0;
}
