#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  vector<long long> vo;
  vector<long long> ve;
  stack<long long> so;
  stack<long long> se;
  int e = 0, o = 0;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1) {
      o++;
      vo.push_back(a[i]);
    } else {
      e++;
      ve.push_back(a[i]);
    }
  }
  sort(vo.begin(), vo.end());
  sort(ve.begin(), ve.end());
  for (int i = 0; i < vo.size(); i++) {
    so.push(vo[i]);
  }
  for (int i = 0; i < ve.size(); i++) {
    se.push(ve[i]);
  }
  if (o == 0) {
    for (int i = 0; i < ve.size() - 1; i++) sum += ve[i];
  } else if (e == 0) {
    for (int i = 0; i < vo.size() - 1; i++) sum += vo[i];
  } else if (e == o || e + 1 == o || e == o + 1)
    sum = 0;
  else if (e > o) {
    se.pop();
    while (!so.empty()) {
      se.pop();
      so.pop();
    }
    while (!se.empty()) {
      sum += se.top();
      se.pop();
    }
  } else if (e < o) {
    so.pop();
    while (!se.empty()) {
      se.pop();
      so.pop();
    }
    while (!so.empty()) {
      sum += so.top();
      so.pop();
    }
  }
  cout << sum << endl;
  return 0;
}
