#include <bits/stdc++.h>
using namespace std;
vector<int> odds, evens;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, tmp;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    if (tmp % 2)
      odds.push_back(tmp);
    else
      evens.push_back(tmp);
  }
  int len = odds.size() - evens.size();
  if (abs(len) < 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(odds.begin(), odds.end());
  sort(evens.begin(), evens.end());
  long long ans = 0;
  if (len > 0) {
    for (int i = 0; i < len - 1; ++i) ans += odds[i];
  } else {
    for (int i = 0; i < len * (-1) - 1; ++i) ans += evens[i];
  }
  cout << ans << endl;
  return 0;
}
