#include <bits/stdc++.h>
using namespace std;
bool cmp(int x, int y) {
  if (x % 2 != y % 2) {
    return x % 2 == 1;
  }
  if (x % 2 == 1) {
    return x > y;
  }
  return x < y;
}
int main() {
  int n, a[2005], sum1 = 0, sum2 = 0, sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1) {
      sum1++;
    } else {
      sum2++;
    }
  }
  sort(a + 1, a + n + 1, cmp);
  if (sum1 >= sum2) {
    for (int i = sum2 + 2; i <= n - sum2; i++) {
      sum += a[i];
    }
  } else {
    for (int i = sum1 + 1; i <= n - sum1 - 1; i++) {
      sum += a[i];
    }
  }
  cout << sum;
  return 0;
}
