#include <bits/stdc++.h>
using namespace std;
long long accumulate(vector<int>::iterator first, vector<int>::iterator last) {
  long long ret = 0;
  while (first != last) {
    ret += *first;
    first++;
  }
  return ret;
}
int main() {
  int n, x;
  vector<int> odd, even;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    x % 2 == 0 ? even.push_back(x) : odd.push_back(x);
  }
  if (abs((int)even.size() - (int)odd.size()) < 2) {
    printf("0\n");
    return 0;
  }
  sort(even.begin(), even.end(), greater<int>());
  sort(odd.begin(), odd.end(), greater<int>());
  long long sum = 0;
  if (even.size() > odd.size())
    sum = accumulate(even.begin() + odd.size() + 1, even.end());
  else
    sum = accumulate(odd.begin() + even.size() + 1, odd.end());
  printf("%lld\n", sum);
  return 0;
}
