#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, r = 0, f, cnt = 0;
  cin >> n;
  int a[n], ev[n], od[n];
  for (int k = 0; k < n; k++) {
    cin >> a[k];
  }
  for (int k = 0; k < n; k++) {
    if (a[k] % 2 == 0) {
      ev[r] = a[k];
      r++;
    } else {
      od[c] = a[k];
      c++;
    }
  }
  sort(ev, ev + r);
  sort(od, od + c);
  f = max(c, r) - min(c, r) - 1;
  if (r > c) {
    for (int k = 0; k < f; k++) {
      cnt = cnt + ev[k];
    }
  } else
    for (int k = 0; k < f; k++) {
      cnt = cnt + od[k];
    }
  cout << cnt;
  return 0;
}
