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