#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n;
  cin >> n;
  long int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long int odd[n];
  memset(odd, 0, n * 4);
  long int even[n];
  memset(even, 0, n * 4);
  long int count1 = 0, count2 = 0, count3 = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] % 2 == 0) {
      count1++;
      even[i] = arr[i];
    } else {
      count2++;
      odd[i] = arr[i];
    }
  }
  sort(even, even + n, greater<int>());
  sort(odd, odd + n, greater<int>());
  if (count2 == 0) {
    for (int i = 1; i < count1; i++) sum = sum + even[i];
    cout << sum;
  } else if (count1 == 0) {
    for (int i = 1; i < count2; i++) sum = sum + odd[i];
    cout << sum;
  } else if (count1 > count2 + 1) {
    count3 = count1 - count2 - 1;
    for (int i = count2 + 1; i <= (count2 + count3); i++) {
      sum = sum + even[i];
    }
    cout << sum;
  } else if (count2 > count1 + 1) {
    count3 = count1 - count2 - 1;
    for (int i = count1 + 1; i <= (count1 + count3); i++) {
      sum = sum + odd[i];
    }
    cout << sum;
  } else
    cout << 0;
}
