#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long a[n], sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  vector<int> b, c;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      b.push_back(a[i]);
    } else
      c.push_back(a[i]);
  }
  sort(b.rbegin(), b.rend());
  sort(c.rbegin(), c.rend());
  int y = min(b.size(), c.size());
  if (y == (n / 2))
    cout << 0;
  else if (y == 0)
    cout << sum - a[0];
  else {
    for (int i = 0; i < y; i++) sum = sum - c[i] - b[i];
    if (y == b.size())
      cout << sum - c[y];
    else
      cout << sum - b[y];
  }
  return 0;
}
