#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  ;
  multiset<int, greater<int>> so, se;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a % 2) {
      so.insert(a);
    } else {
      se.insert(a);
    }
  }
  bool odd = 0;
  if (so.size() > se.size()) odd = 1;
  while (true) {
    if (odd) {
      if (so.size() == 0) break;
      so.erase(so.begin());
      odd = 0;
    } else {
      if (se.size() == 0) break;
      se.erase(se.begin());
      odd = 1;
    }
  }
  long long sum = 0;
  while (so.size() > 0) {
    sum += (*so.begin());
    so.erase(so.begin());
  }
  while (se.size() > 0) {
    sum += (*se.begin());
    se.erase(se.begin());
  }
  cout << sum << "\n";
  return 0;
}
