#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  long long int odd = 0;
  long long int even = 0;
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] & 1)
      odd++;
    else
      even++;
  }
  sort(a, a + n);
  if (even == n / 2 || odd == n / 2)
    cout << "0" << endl;
  else {
    if (even > odd) {
      long long int e = 0, o = 0;
      for (int i = n - 1; i >= 0; i--) {
        if (a[i] & 1)
          o++;
        else
          e++;
        sum -= a[i];
        if (odd == o && e == odd + 1) break;
      }
    } else {
      long long int e = 0, o = 0;
      for (int i = n - 1; i >= 0; i--) {
        if (a[i] & 1)
          o++;
        else
          e++;
        sum -= a[i];
        if (e == even && o == even + 1) break;
      }
    }
    cout << sum << endl;
    return 0;
  }
}
