#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 1e5 + 5;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  long long a[n + 5], ans = 0, maxx = 0, sum = 0;
  vector<long long> e, o;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] & 1)
      e.push_back(a[i]);
    else
      o.push_back(a[i]);
    maxx = max(a[i], maxx);
    sum += a[i];
  }
  sort(e.begin(), e.end()), sort(o.begin(), o.end());
  long long es = (long long)e.size(), os = (long long)o.size();
  if (abs(es - os) <= 1) {
    cout << 0;
    return 0;
  }
  if (es == 0 || os == 0) {
    cout << sum - maxx;
    return 0;
  }
  if (es > os) {
    for (int i = 0; i < (es - os - 1); i++) {
      ans += e[i];
    }
  } else {
    for (int i = 0; i < (os - es - 1); i++) {
      ans += o[i];
    }
  }
  cout << ans;
  return 0;
}
