#include <bits/stdc++.h>
using namespace std;
int a[2020], b[2020];
int t1, t2;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int x;
    scanf("%d", &x);
    if (x % 2)
      a[t1++] = x;
    else
      b[t2++] = x;
  }
  if (abs(t1 - t2) <= 1)
    printf("0");
  else {
    sort(a, a + t1);
    sort(b, b + t2);
    if (t1 < t2) {
      int ans = 0;
      for (int i = 0; i < t2 - t1 - 1; i++) {
        ans += b[i];
      }
      printf("%d", ans);
    } else {
      int ans = 0;
      for (int i = 0; i < t1 - t2 - 1; i++) {
        ans += a[i];
      }
      printf("%d", ans);
    }
  }
}
