#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long int s = 0, k = 0;
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    if (a[i] % 2)
      k++;
    else
      s++;
  }
  if (s == k || s == k + 1 || s + 1 == k) {
    cout << 0 << "\n";
    return 0;
  } else if (s > k) {
    for (int i = 0; i < s - k - 1; i++) {
      if (a[i] % 2 == 0) sum += a[i];
    }
    cout << sum << "\n";
  } else {
    for (int i = 0; i < k - s - 1; i++) {
      if (a[i] % 2) sum += a[i];
    }
    cout << sum << "\n";
    return 0;
  }
}
