#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int input;
  int odd[2000 + 10];
  int even[2000 + 10];
  int count_even = 0, count_odd = 0;
  for (int i = 0; i < n; i++) {
    cin >> input;
    if (input % 2 == 0) {
      even[count_even] = input;
      count_even++;
    } else {
      odd[count_odd] = input;
      count_odd++;
    }
  }
  sort(even, even + count_even);
  sort(odd, odd + count_odd);
  int sum = 0;
  int number = abs(count_even - count_odd) - 1;
  if (count_even - count_odd > 1) {
    for (int i = 0; i < number; i++) sum += even[i];
  } else if (count_odd - count_even > 1) {
    for (int i = 0; i < number; i++) sum += odd[i];
  }
  cout << endl << sum;
}
