#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
int main() {
  long long int n, a, b, i, ci = 0, cp = 0, r = 0;
  cin >> n;
  vector<long long int> vp, vi;
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0) {
      vp.push_back(a);
    } else {
      vi.push_back(a);
    }
  }
  ci = vi.size();
  cp = vp.size();
  sort(vp.begin(), vp.end());
  sort(vi.begin(), vi.end());
  if (ci > (cp + 1)) {
    for (long long int i = 0; i < (ci - (cp + 1)); i++) {
      r = r + vi[i];
    }
  } else if ((ci + 1) < cp) {
    for (long long int i = 0; i < (cp - (ci + 1)); i++) {
      r = r + vp[i];
    }
  }
  cout << r;
  return 0;
}
