#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int even = 0, odd = 0;
  vector<int> v(n);
  for (int& x : v) {
    cin >> x;
    x % 2 == 1 ? ++odd : ++even;
  }
  if (min(odd, even) * 2 == n) {
    cout << 0;
    return 0;
  }
  sort(v.rbegin(), v.rend());
  int sum = 0;
  bool taken = false;
  even = odd = min(even, odd);
  for (int x : v) {
    if (not taken and ((x % 2 == 0 and not even) or (x % 2 == 1 and not odd))) {
      taken = true;
      continue;
    }
    if (x % 2 == 0)
      even ? --even : sum += x;
    else
      odd ? --odd : sum += x;
  }
  cout << sum;
}
