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