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