#include <bits/stdc++.h>
int odd[2005];
int even[2005];
bool cmp(int a, int b) { return a < b; }
using namespace std;
int main() {
  int n, t, leno = 1, lene = 1;
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &t);
    if (t & 1) {
      even[lene] = t;
      lene++;
    } else {
      odd[leno] = t;
      leno++;
    }
  }
  lene--;
  leno--;
  if (abs(lene - leno) == 1 || abs(lene - leno) == 0) {
    printf("0");
    return 0;
  }
  sort(odd + 1, odd + 1 + leno, cmp);
  sort(even + 1, even + 1 + lene, cmp);
  int sum = 0;
  for (i = 1; i <= abs(leno - lene) - 1; i++) {
    if (leno > lene)
      sum += odd[i];
    else
      sum += even[i];
  }
  printf("%d", sum);
  return 0;
}
