#include <bits/stdc++.h>
using namespace std;
vector<int> odd, even;
int main() {
  int n, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a & 1) odd.push_back(a);
    even.push_back(a);
    sum += a;
  }
  sort(odd.rbegin(), odd.rend());
  sort(even.rbegin(), even.rend());
  int k = min(odd.size(), even.size());
  sum -= accumulate(odd.begin(), odd.begin() + k, 0);
  sum -= accumulate(even.begin(), even.begin() + k, 0);
  if (k < odd.size()) sum -= odd[k];
  if (k < even.size()) sum -= even[k];
  cout << sum;
}
