#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, c = 0;
  int d = 0, s = 0;
  cin >> n;
  int a[n], b[n], f[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    s = s + a[i];
  }
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      b[c] = a[i];
      c++;
    } else {
      f[d] = a[i];
      d++;
    }
  }
  int k = min(c, d);
  for (i = 0; i < k; i++) {
    s = s - b[i] - f[i];
  }
  if (d > c)
    s = s - f[k];
  else
    s = s - b[k];
  cout << s;
  return 0;
}
