#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> vec(n);
  int odd = 0, eve = 0;
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    if (vec[i] % 2 == 0)
      eve++;
    else
      odd++;
  }
  if (eve == odd + 1 || odd == eve + 1 || eve == odd) {
    cout << 0 << endl;
    return 0;
  }
  int cur = max(odd, eve) - min(odd, eve) - 1;
  long long int sum = 0;
  sort(vec.begin(), vec.end());
  if (odd > eve) {
    for (int i = 0; i < cur; i++) {
      if (vec[i] % 2 == 1) sum += vec[i];
    }
  } else {
    for (int i = 0; i < cur; i++) {
      if (vec[i] % 2 == 0) sum += vec[i];
    }
  }
  cout << sum << endl;
  return 0;
}
