#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, sum;
  cin >> n;
  vector<int> v(n);
  int cantPar, cantImpar;
  cantPar = cantImpar = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] % 2 == 0)
      ++cantPar;
    else
      ++cantImpar;
  }
  if (abs(cantPar - cantImpar) < 2)
    cout << 0 << "\n";
  else {
    sum = 0;
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < abs(cantPar - cantImpar) - 1; i++) {
      sum += v[i];
    }
    cout << sum << "\n";
  }
  return 0;
}
