#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> V(n);
  for (int i = 0; i < n; ++i) cin >> V[i];
  vector<long long> odd, even;
  sort(V.begin(), V.end(), greater<int>());
  long long total = 0;
  for (int i = 0; i < n; ++i) {
    if (V[i] % 2)
      odd.push_back(V[i]);
    else
      even.push_back(V[i]);
    total += V[i];
  }
  int turn = odd.size() > even.size(), a = 0, b = 0;
  while (true) {
    if (turn) {
      if (a >= odd.size()) break;
      total -= odd[a];
      a++;
    } else {
      if (b >= even.size()) break;
      total -= even[b];
      b++;
    }
    turn = !turn;
  }
  cout << total << "\n";
  return 0;
}
