#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[3000] = {0};
  long long eve = 0;
  long long odd = 0;
  long long x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[i] = x;
    if ((a[i] % 2) == 0) {
      eve++;
    } else {
      odd++;
    }
  }
  long long r = abs(eve - odd);
  long long sum;
  long long ans = 0;
  if (r != 0 && r != 1) {
    sort(a, a + n);
    if (eve > odd) {
      sum = eve - odd - 1;
      for (int k = 0; k < sum; k++) {
        ans += a[k];
      }
    }
    if (eve < odd) {
      sum = odd - eve - 1;
      for (int j = 0; j < sum; j++) {
        ans += a[j];
      }
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
