#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const int MAX = 1e5 + 7;
const long MOD = 1e9 + 9;
const long INF = 1e15;
int main() {
  int n;
  cin >> n;
  long long int arr[n], ev = 0, od = 0, sume = 0, sumo = 0;
  vector<int> vec1, vec2;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0) {
      vec1.push_back(arr[i]);
      ev++;
    } else {
      vec2.push_back(arr[i]);
      od++;
    }
  }
  sort(vec1.begin(), vec1.end());
  sort(vec2.begin(), vec2.end());
  if (abs(ev - od) == 1)
    cout << "0";
  else if (ev == od) {
    for (long long int i = 0; i < vec1.size(); i++) sume += vec1[i];
    for (long long int i = 0; i < vec2.size(); i++) sumo += vec2[i];
    if (sume > sumo)
      cout << vec2[0];
    else
      cout << vec1[0];
  } else if (ev > od) {
    for (long long int i = 0; i < vec1.size() - od - 1; i++) sume += vec1[i];
    cout << sume;
  } else {
    for (long long int i = 0; i < vec2.size() - ev - 1; i++) sume += vec2[i];
    cout << sume;
  }
}
