#include <bits/stdc++.h>
using namespace std;
int n, a[10000], x, y, k = 0, ans = 0;
bool b[10000];
int main() {
  int i, j;
  cin >> n;
  x = 0;
  y = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1) {
      x += 1;
      b[i] = 1;
    } else {
      y += 1;
      b[i] = 0;
    }
  }
  if (x == y || x + 1 == y || y + 1 == x)
    cout << 0 << endl;
  else {
    if (x > y) {
      sort(a + 1, a + n + 1);
      for (i = 1; i <= n; i++) {
        if (a[i] % 2 == 1 && k != (x - y - 1)) {
          ans += a[i];
          k += 1;
        }
      }
      cout << ans << endl;
    } else {
      sort(a + 1, a + n + 1);
      for (i = 1; i <= n; i++) {
        if (a[i] % 2 == 0 && k != (y - x - 1)) {
          ans += a[i];
          k += 1;
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}
