#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> e, o;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t & 1)
      o.push_back(t);
    else
      e.push_back(t);
  }
  if (!o.empty()) sort((o).begin(), (o).end());
  if (!e.empty()) sort((e).begin(), (e).end());
  int d = o.size() - e.size(), os = 0, es = 0;
  for (int i = 0; i < d - 1; i++) os += o[i];
  for (int i = 0; i < -d - 1; i++) es += e[i];
  cout << (d > 0 ? os : es);
}
signed main() {
  ios_base::sync_with_stdio(false);
  int t = 1;
  while (t--) solve();
  return 0;
}
