#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n), k(n);
  int odd = 0, even = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] % 2 == 0)
      even++;
    else
      odd++;
  }
  if (even - odd == 0 || abs(even - odd) == 1) {
    cout << 0;
    return 0;
  }
  int dif = even - odd, ans = 0;
  sort(v.begin(), v.end());
  if (dif > 0) {
    dif = abs(dif);
    for (int i = 0; i < n && dif != 1; i++)
      if (v[i] % 2 == 0) dif--, ans += v[i];
  } else {
    dif = abs(dif);
    for (int i = 0; i < n && dif != 1; i++)
      if (v[i] % 2 != 0) dif--, ans += v[i];
  }
  cout << ans;
}
