#include <bits/stdc++.h>
using namespace std;
int A[10000], B[10000];
int i, n, x, x1, x2;
long long sum;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (x % 2 == 0)
      A[x1++] = x;
    else
      B[x2++] = x;
  }
  sort(A, A + x1);
  sort(B, B + x2);
  if (x1 > x2) {
    x2 = x1 - x2 - 1;
    for (i = 0; i < x2; i++) sum += A[i];
  } else {
    x2 = x2 - x1 - 1;
    for (i = 0; i < x2; i++) sum += B[i];
  }
  cout << sum;
  return 0;
}
