#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 1 * 1000 * 1000 * 1000 + 200;
const int MAXN = 5 * 100 * 1000 + 10;
const int MLOG = 30;
const int NMAX = 20;
int main() {
  int n;
  cin >> n;
  int nm[2] = {0, 0}, a;
  vector<int> vc[2];
  for (int i = 0; i < n; i++) cin >> a, nm[a % 2]++, vc[a % 2].push_back(a);
  int h = 1;
  if (nm[0] > nm[1]) swap(nm[1], nm[0]), h = 0;
  int all = max(0, nm[1] - nm[0] - 1), ans = 0;
  sort(vc[h].begin(), vc[h].end());
  for (int i = 0; i < all; i++) ans += vc[h][i];
  cout << ans;
}
