#include <bits/stdc++.h>
using namespace std;
int a[2005];
int main() {
  int n;
  cin >> n;
  int jj = 0, oo = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      jj++;
    else
      oo++;
  }
  if (jj == oo || abs(jj - oo) == 1) {
    cout << "0" << endl;
    return 0;
  }
  sort(a, a + n);
  if (jj > oo) {
    long long int ans = 0;
    int l = jj - oo - 1;
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0) {
        ans += a[i];
        l--;
      }
      if (l == 0) break;
    }
    cout << ans << endl;
  }
  if (oo > jj) {
    long long int ans = 0;
    int l = oo - jj - 1;
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 != 0) {
        ans += a[i];
        l--;
      }
      if (l == 0) break;
    }
    cout << ans << endl;
  }
}
