#include <bits/stdc++.h>
using namespace std;
int a[2055];
int b[2005];
int c[2005];
int main() {
  int n;
  scanf("%d", &n);
  int q1 = 0, q2 = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ans += a[i];
    if (a[i] % 2)
      b[++q1] = a[i];
    else
      c[++q2] = a[i];
  }
  sort(b + 1, b + q1 + 1);
  sort(c + 1, c + q2 + 1);
  if (q1 < q2) {
    int sum = 0;
    for (int i = 1; i <= q1; i++) sum += b[i];
    for (int i = max(1, q2 - q1); i <= q2; i++) sum += c[i];
    printf("%d\n", ans - sum);
  } else {
    int sum = 0;
    for (int i = 1; i <= q2; i++) sum += c[i];
    for (int i = max(1, q1 - q2); i <= q1; i++) sum += b[i];
    printf("%d\n", ans - sum);
  }
}
