#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  int odd = 0, even = 0;
  vector<int> ev, od;
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] % 2 == 0) {
      even++;
      ev.push_back(a[i]);
    } else {
      odd++;
      od.push_back(a[i]);
    }
  }
  if (ev.size() == 0 || od.size() == 0) {
    cout << sum;
    return 0;
  }
  sort(ev.rbegin(), ev.rend());
  sort(od.rbegin(), od.rend());
  int p1 = 0, p2 = 0, k = 0;
  if (od.size() > ev.size()) k = 1;
  if (even == odd) {
    cout << 0;
    return 0;
  } else {
    while (p1 < ev.size() && p2 < od.size()) {
      if (k % 2 == 0)
        p1++;
      else
        p2++;
      k++;
    }
  }
  if (p1 == ev.size()) {
    long long int sum = 0;
    for (int i = p2; i < od.size() - 1; i++) sum += od[i];
    cout << sum;
    return 0;
  } else {
    long long int sum = 0;
    for (int i = p1; i < od.size() - 1; i++) sum += ev[i];
    cout << sum;
    return 0;
  }
  return 0;
}
