#include <bits/stdc++.h>
using namespace std;
inline void PRE() {
  cout << fixed << showpoint;
  cout << setprecision(9);
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i = 0;
  cin >> n;
  vector<long long> o, e;
  for (i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    if (a % 2 == 0)
      e.push_back(a);
    else
      o.push_back(a);
  }
  long long sum;
  sort(o.begin(), o.end());
  sort(e.begin(), e.end());
  if (o.size() > e.size()) {
    long long nn = o.size() - e.size();
    sum = 0;
    for (i = 0; i < nn - 1; ++i) {
      sum += o[i];
    }
  } else {
    long long nn = e.size() - o.size();
    sum = 0;
    for (i = 0; i < nn - 1; ++i) {
      sum += e[i];
    }
  }
  cout << sum << "\n";
  return 0;
}
