#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
  return *(int *)a < *(int *)b ? 1 : -1;
}
int main() {
  int n, a[2100], od[2100], ev[2100], odd = 0, even = 0;
  int i, j, k, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", a + i);
    if (a[i] % 2 == 0)
      even++;
    else
      odd++;
  }
  if (even == odd || even == odd + 1 || odd == even + 1) {
    printf("0\n");
  } else {
    qsort(a, n, sizeof(int), compare);
    j = 0, k = 0;
    for (i = 0; i < n; ++i) {
      if (a[i] % 2 == 0)
        ev[j++] = a[i];
      else
        od[k++] = a[i];
    }
    if (odd > even) {
      for (i = even + 1; i < odd; ++i) {
        sum += od[i];
      }
    } else {
      for (i = odd + 1; i < even; ++i) {
        sum += ev[i];
      }
    }
    printf("%d", sum);
  }
  return 0;
}
