#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, e = 0, d = 0;
  cin >> n;
  long long int ara[n];
  for (long long int i = 0; i < n; i++) {
    cin >> ara[i];
    if (ara[i] % 2 == 0)
      e++;
    else
      d++;
  }
  sort(ara, ara + n);
  if (abs(e - d) == 1 || abs(e - d) == 0) {
    cout << 0 << endl;
    return 0;
  }
  long long int i = 0, sum = 0;
  if (e < d) {
    d -= (e + 1);
    while (d) {
      if (ara[i] % 2) {
        sum += ara[i];
        d--;
      }
      i++;
    }
    cout << sum << endl;
    return 0;
  }
  if (e > d) {
    e -= (d + 1);
    while (e) {
      if (ara[i] % 2 == 0) {
        sum += ara[i];
        e--;
      }
      i++;
    }
    cout << sum << endl;
    return 0;
  }
}
