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