#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> odd, even;
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    sum += x;
    if (x & 1)
      odd.push_back(x);
    else
      even.push_back(x);
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  reverse(odd.begin(), odd.end());
  reverse(even.begin(), even.end());
  int sz = min(odd.size(), even.size());
  sum -= accumulate(odd.begin(), odd.begin() + sz, 0);
  sum -= accumulate(even.begin(), even.begin() + sz, 0);
  if (odd.size() > sz)
    sum -= odd[sz];
  else if (even.size() > sz)
    sum -= even[sz];
  printf("%lld\n", sum);
  return 0;
}
