#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> odd, even;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x & 1)
      odd.push_back(x);
    else
      even.push_back(x);
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  if (min(odd.size(), even.size()) + 1 == max(odd.size(), even.size()) or
      even.size() == odd.size())
    cout << "0" << endl;
  else {
    long long sum = 0;
    if (even.size() == max(odd.size(), even.size())) {
      for (int i = 0; i < max(odd.size(), even.size()) -
                              (min(odd.size(), even.size()) + 1);
           i++)
        sum += even[i];
    } else {
      for (int i = 0; i < max(odd.size(), even.size()) -
                              (min(odd.size(), even.size()) + 1);
           i++)
        sum += odd[i];
    }
    cout << sum << endl;
  }
  return 0;
}
