#include <bits/stdc++.h>
using namespace std;
int even_array[10001];
int odd_array[10001];
bool cmp(int a, int b) { return a > b; }
int main() {
  int i, j, n;
  int minn, tok;
  int tmp;
  int odd = 0, even = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &tmp);
    if (tmp % 2 == 0) {
      even_array[++even] = tmp;
    } else {
      odd_array[++odd] = tmp;
    }
  }
  if (even == odd) {
    printf("0\n");
    return 0;
  }
  sort(even_array + 1, even_array + 1 + even, cmp);
  sort(odd_array + 1, odd_array + 1 + odd, cmp);
  if (abs(even - odd) == 1) {
    printf("0\n");
    return 0;
  }
  long long sum = 0;
  minn = min(even, odd);
  if (even > odd) {
    for (i = minn + 2; i <= even; i++) {
      sum += even_array[i];
    }
  } else {
    for (i = minn + 2; i <= odd; i++) {
      sum += odd_array[odd];
    }
  }
  printf("%lld\n", sum);
  return 0;
}
