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