#include <bits/stdc++.h>
using namespace std;
vector<int> odd;
vector<int> even;
int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  int r;
  while (n--) {
    int tmp;
    scanf("%d", &tmp);
    sum += tmp;
    if (tmp % 2)
      odd.push_back(tmp);
    else
      even.push_back(tmp);
  }
  sort(odd.rbegin(), odd.rend());
  sort(even.rbegin(), even.rend());
  int k = min(odd.size(), even.size());
  for (int i = 0; i < k; i++) {
    sum -= odd[i];
    sum -= even[i];
  }
  if ((int)odd.size() > k) {
    sum -= odd[k];
  }
  if ((int)even.size() > k) {
    sum -= even[k];
  }
  printf("%d", sum);
  return 0;
}
