#include <bits/stdc++.h>
using namespace std;
int ans(int n) {
  vector<int> eve;
  vector<int> odd;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    if (temp % 2 == 0)
      eve.push_back(temp);
    else
      odd.push_back(temp);
  }
  sort(eve.begin(), eve.end());
  sort(odd.begin(), odd.end());
  int evesum{0}, oddsum{0};
  for (int i = 0; i < eve.size(); i++) evesum = evesum + eve[i];
  for (int i = 0; i < odd.size(); i++) oddsum = oddsum + odd[i];
  if (eve.size() == odd.size()) return 0;
  if (eve.size() == 0) return oddsum - odd[odd.size() - 1];
  if (odd.size() == 0) return evesum - eve[eve.size() - 1];
  if (odd.size() != eve.size()) {
    int sum = 0;
    int temp = odd.size() - eve.size();
    if (temp > 0) {
      int temp2 = temp - 1;
      if (temp2 == 0)
        return 0;
      else {
        for (int i = 0; i < temp - 1; i++) sum = sum + odd[i];
        return sum;
      }
    }
    if (temp < 0) {
      temp = -temp;
      int temp2 = temp - 1;
      if (temp2 == 0)
        return 0;
      else {
        for (int i = 0; i < temp - 1; i++) sum = sum + eve[i];
        return sum;
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  cout << ans(n);
}
