#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a;
  priority_queue<long long int> o, e;
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0)
      e.push(a);
    else
      o.push(a);
  }
  if (e.size() == o.size()) {
    cout << 0;
    return 0;
  }
  long long int mi = min(e.size(), o.size());
  if (e.size() == mi) {
    for (long long int i = 0; i < mi; i++) e.pop();
    for (long long int i = 0; i < mi + 1; i++) o.pop();
  } else {
    for (long long int i = 0; i < mi; i++) o.pop();
    for (long long int i = 0; i < mi + 1; i++) e.pop();
  }
  long long int sum = 0;
  while (!e.empty()) {
    sum += e.top();
    e.pop();
  }
  while (!o.empty()) {
    sum += o.top();
    o.pop();
  }
  cout << sum;
}
