#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> e, o;
  for (long long i = (0); i < (n); i++) {
    long long a;
    cin >> a;
    if (a % 2)
      o.push_back(a);
    else
      e.push_back(a);
  }
  sort(e.begin(), e.end());
  sort(o.begin(), o.end());
  if (e.size() > o.size()) {
    long long ans = 0;
    for (long long i = (0); i < (e.size() - (o.size() + 1)); i++) ans += e[i];
    cout << ans << endl;
  } else {
    long long ans = 0;
    for (long long i = (0); i < ((long long)o.size() - (e.size() + 1)); i++)
      ans += o[i];
    cout << ans << endl;
  }
  return 0;
}
