#include <bits/stdc++.h>
using namespace std;
long long int bin(vector<long long int> vec, long long int l, long long int r,
                  long long int x) {
  if (r >= l) {
    long long int mid = l + (r - l) / 2;
    if (vec[mid] == x) return mid;
    if (vec[mid] > x) return bin(vec, l, mid - 1, x);
    return bin(vec, mid + 1, r, x);
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> vec(n);
  long long int i;
  for (i = 0; i < n; i++) cin >> vec[i];
  long long int odd = 0, even = 0;
  sort(vec.begin(), vec.end());
  long long int cr;
  for (i = 0; i < n; i++) {
    if (vec[i] % 2 == 0)
      even++;
    else
      odd++;
  }
  long long int t = 0;
  long long int sum = 0;
  if (even == odd || odd + 1 == even || even + 1 == odd)
    cout << 0;
  else {
    if (even > odd) {
      cr = even - odd - 1;
      for (i = 0; i < n, t < cr; i++) {
        if (vec[i] % 2 == 0) {
          sum += vec[i];
          t++;
        }
      }
    } else {
      cr = odd - even - 1;
      for (i = 0; i < n, t < cr; i++) {
        if (vec[i] % 2 != 0) {
          sum += vec[i];
          t++;
        }
      }
    }
  }
  cout << sum;
  return 0;
}
