#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void) {
  cin.tie(0)->sync_with_stdio(false);
  int n;
  cin >> n;
  ll arr[n];
  vector<ll> o;
  vector<ll> e;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2)
      o.push_back(arr[i]);
    else
      e.push_back(arr[i]);
  }
  sort(o.begin(), o.end());
  sort(e.begin(), e.end());
  int num = min(o.size(), e.size());
  o.resize(o.size() - num);
  e.resize(e.size() - num);
  ll sum = 0;
  if (o.size() == 0 && e.size() == 0) {
    cout << 0 << '\n';
    return 0;
  }
  if (o.size() == 0) {
    for (int i = 0; i < e.size() - 1; i++) {
      sum += e[i];
    }
  } else if (e.size() == 0) {
    for (int i = 0; i < o.size() - 1; i++) {
      sum += o[i];
    }
  }
  cout << sum << '\n';
  return 0;
}
