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