#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a, b;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (x % 2 == 0)
      a.push_back(x);
    else
      b.push_back(x);
  }
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  long long mn;
  long long sum = 0;
  if (a.size() == b.size())
    sum = 0;
  else if (a.size() < b.size()) {
    if (a.size() == 0)
      b.erase(b.begin());
    else
      b.erase(b.begin(), b.begin() + a.size() + 1);
    sum = accumulate(b.begin(), b.end(), 0);
  } else if (a.size() > b.size()) {
    if (b.size() == 0)
      a.erase(a.begin());
    else
      a.erase(a.begin(), a.begin() + b.size() + 1);
    sum = accumulate(a.begin(), a.end(), 0);
  }
  cout << sum;
}
int main() { solve(); }
