#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, temp;
  int l1 = 0, l2 = 0;
  vector<int> ji;
  vector<int> ou;
  cin >> n;
  while (n--) {
    cin >> temp;
    if (temp % 2 == 0)
      ou.push_back(temp);
    else
      ji.push_back(temp);
  }
  l1 = ji.size();
  l2 = ou.size();
  if (l1 == l2) {
    cout << 0;
    return 0;
  }
  sort(ji.begin(), ji.end());
  sort(ou.begin(), ou.end());
  int s = 0;
  if (l1 > l2) {
    for (int i = 0; i < l1 - l2 - 1; ++i) s += ji[i];
  } else
    for (int i = 0; i < l2 - l1 - 1; ++i) s += ou[i];
  cout << s;
  return 0;
}
