#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int num;
  int c1 = 0, c2 = 0;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (num % 2 == 0 && num != 1) {
      a[c1++] = num;
    } else
      b[c2++] = num;
  }
  sort(a, a + c1);
  sort(b, b + c2);
  long long ans = 0;
  if (c1 == c2) {
    cout << 0;
    return 0;
  } else if (c1 - c2 > 1) {
    for (int i = 0; i < c1 - c2 - 1; i++) {
      ans += a[i];
    }
    cout << ans;
    return 0;
  } else
    for (int i = 0; i < c1 - c2 - 1; i++) {
      ans += b[i];
    }
  cout << ans;
  return 0;
}
