#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, a;
  cin >> n;
  vector<long> even, odd;
  while (n--) {
    cin >> a;
    if (a % 2 == 0)
      even.push_back(a);
    else
      odd.push_back(a);
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  reverse(odd.begin(), odd.end());
  reverse(even.begin(), even.end());
  int ol = (int)odd.size();
  int el = (int)even.size();
  int longer = ol > el ? ol : el;
  int length = 0;
  if (ol == el)
    length = el;
  else
    length = ol > el ? el + 1 : ol + 1;
  long res = 0;
  vector<long> toiter = longer == ol ? odd : even;
  for (int i = length; i < longer; i++) {
    res += toiter[i];
  }
  cout << res << endl;
  return 0;
}
