#include <bits/stdc++.h>
using namespace std;
int n, od[2010], ev[2010], cnt1 = 0, cnt2 = 0, sum = 0;
bool cmp(int _, int __) { return _ > __; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    if (a % 2 != 0)
      od[++cnt1] = a;
    else
      ev[++cnt2] = a;
  }
  sort(od + 1, od + cnt1 + 1, cmp);
  sort(ev + 1, ev + cnt2 + 1, cmp);
  int x = min(cnt1, cnt2);
  int xx = x;
  for (++x; x <= max(cnt1, cnt2); x++) sum += od[x] + ev[x];
  printf("%d", sum - max(od[xx + 1], ev[xx + 1]));
  return 0;
}
