#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 temp;
    cin >> temp;
    if (temp % 2)
      even.push_back(temp);
    else
      odd.push_back(temp);
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  reverse(even.begin(), even.end());
  reverse(odd.begin(), odd.end());
  int ind = min((int)even.size(), (int)odd.size());
  int ans = 0;
  for (int i = ind; i < even.size(); i++) ans += even[ind];
  for (int i = ind; i < odd.size(); i++) ans += odd[ind];
  int val = 0;
  if (ind < even.size()) val = even[ind];
  if (ind < odd.size()) val = max(val, odd[ind]);
  cout << ans - val << endl;
}
