#include <bits/stdc++.h>
using namespace std;
int a[20005];
int main() {
  int n;
  cin >> n;
  int s1, s2;
  s1 = s2 = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (a[i] % 2)
      s1++;
    else
      s2++;
  }
  if (s1 == s2 || s1 == s2 - 1 || s2 == s1 - 1)
    printf("0\n");
  else {
    int s = 0;
    int cnt, l;
    if (s1 > s2) {
      l = s1 - s2 - 1;
      cnt = 1;
    } else {
      l = s2 - s1 - 1;
      cnt = 0;
    }
    int k = 0;
    for (int i = 1;; i++) {
      if (cnt && a[i] % 2) {
        s += a[i];
        k++;
      }
      if (cnt == 0 && a[i] % 2 == 0) {
        s += a[i];
        k++;
      }
      if (k == l)
        ;
      break;
    }
    printf("%d\n", s);
  }
  return 0;
}
