#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<int> odd, eve;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x & 1)
      odd.push_back(x);
    else
      eve.push_back(x);
  }
  sort(odd.begin(), odd.end(), greater<int>());
  sort(eve.begin(), eve.end(), greater<int>());
  int os = odd.size();
  int es = eve.size();
  int mx = min(es, os);
  int rem = mx + 1;
  long long sum = 0;
  if (es > os) {
    for (int i = rem; i < es; i++) sum += eve[i];
  } else {
    for (int i = rem; i < os; i++) sum += odd[i];
  }
  cout << sum << endl;
}
