#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;
  int a[n + 5];
  int o = 0, e = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] & 1)
      o++;
    else
      e++;
  }
  if (o == e || abs(o - e) == 1)
    cout << 0 << "\n";
  else {
    int ans = 0;
    set<int> ev, od;
    for (int i = 0; i < n; i++) {
      if (a[i] & 1)
        od.insert(a[i]);
      else
        ev.insert(a[i]);
    }
    if (e > o) {
      int x = e - o - 1;
      for (auto i : ev) {
        if (x == 0) break;
        x--;
        ans += i;
      }
    }
    if (o > e) {
      int x = o - e - 1;
      for (auto i : od) {
        if (x == 0) break;
        x--;
        ans += i;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
