#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  int a[2005];
  int even[2005], odd[2005];
  scanf("%d", &n);
  int k1 = 0, k2 = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] % 2 == 0)
      even[k1++] = a[i];
    else
      odd[k2++] = a[i];
  }
  sort(even, even + k1);
  sort(odd, odd + k2);
  int count = 0, sum = 0;
  if (k1 > k2 + 1) {
    k1--;
    count = 0;
    for (i = 0; i < k1; i++) {
      if (count == k2 - k1 - 1) break;
      sum += even[i], count++;
    }
  } else if (1 + k1 < k2) {
    k2--;
    count = 0;
    for (i = 0; i < k2; i++) {
      if (odd[i] == -1) continue;
      if (count == k1 - k2 - 1) break;
      sum += odd[i], count++;
    }
  }
  printf("%d", sum);
  return 0;
}
