#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, j, i, k;
  int q = 0, w = 0, sum = 0;
  int x[10000], y[10000], z[10000];
  while (~scanf("%d", &n)) {
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    memset(z, 0, sizeof(z));
    j = 0, k = 0, m = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &x[i]);
      if (x[i] % 2 == 0) {
        m++;
        y[i] = x[i];
      } else {
        j++;
        z[i] = x[i];
      }
    }
    sort(y, y + m);
    sort(z, z + k);
    if (m == j || m - j == 1 || j - m == 1) {
      printf("%d\n", 0);
    } else {
      if (m > j) {
        q = m - j - 1;
        for (i = 0; i < q; i++) {
          sum += y[i];
        }
      } else {
        w = j - m - 1;
        for (i = 0; i < w; i++) {
          sum += y[i];
        }
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
