#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long sum = 0;
  vector<long long> even;
  vector<long long> odd;
  for (long long i = 0; i < n; i++) {
    long long k;
    cin >> k;
    if (k % 2 != 0) {
      odd.push_back(k);
    } else {
      even.push_back(k);
    }
  }
  for (long long i = 0; i < even.size(); i++) {
    sum += even[i];
  }
  sum = 0;
  sort(odd.begin(), odd.end(), greater<long long>());
  sort(even.begin(), even.end(), greater<long long>());
  if (odd.size() > even.size()) {
    for (long long i = even.size() + 1; i < odd.size(); i++) sum += odd[i];
  }
  if (even.size() > odd.size()) {
    for (long long i = odd.size() + 1; i < even.size(); i++) {
      sum += even[i];
    }
  }
  cout << sum << endl;
  return 0;
}
