#include <bits/stdc++.h>
using namespace std;
vector<int> od, ev;
int main() {
  int n, total = 0, x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    total += x;
    if (x % 2 == 0) {
      ev.push_back(x);
    } else {
      od.push_back(x);
    }
  }
  sort(ev.begin(), ev.end(), greater<int>());
  sort(od.begin(), od.end(), greater<int>());
  int curmax = 0, count = 0;
  if (ev.size() > od.size()) {
    for (int i = 0; i < od.size(); i++) {
      count += ev[i];
      count += od[i];
    }
    count += ev[od.size()];
  } else {
    for (int i = 0; i < ev.size(); i++) {
      count += od[i];
      count += ev[i];
    }
    count += od[ev.size()];
  }
  printf("%d\n", total - count);
  return 0;
}
