#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, x, sum;
  cin >> n;
  vector<int> vPar;
  vector<int> vImpar;
  sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x % 2 == 0)
      vPar.push_back(x);
    else
      vImpar.push_back(x);
    sum += x;
  }
  sort(vPar.begin(), vPar.end());
  sort(vImpar.begin(), vImpar.end());
  int k = min(vImpar.size(), vPar.size());
  if (vPar.size() > 0) {
    sum -= vPar[0];
    vPar[0] = 0;
  } else if (vImpar.size() > 0) {
    sum -= vImpar[0];
    vImpar[0] = 0;
  }
  for (int i = 0; i < k; i++) {
    sum -= vImpar[i];
    sum -= vPar[i];
  }
  if (vImpar.size() == k)
    sum -= vPar[k];
  else
    sum -= vImpar[k];
  cout << sum << "\n";
  return 0;
}
