#include <bits/stdc++.h>
using namespace std;
vector<int> v2, v3, v4, v5;
int main() {
  int N, i;
  cin >> N;
  int a[N];
  for (i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      v2.push_back(a[i]);
      v4.push_back(a[i]);
    } else {
      v3.push_back(a[i]);
      v5.push_back(a[i]);
    }
  }
  sort(v2.begin(), v2.end());
  sort(v3.begin(), v3.end());
  sort(v4.begin(), v4.end());
  sort(v5.begin(), v5.end());
  while (1) {
    if (v2.size() == 0) break;
    v2.pop_back();
    if (v3.size() == 0) break;
    v3.pop_back();
  }
  int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
  int t = max(v2.size(), v3.size());
  if (v2.size() == t) {
    for (i = 0; i < v2.size(); i++) sum1 += v2[i];
  } else {
    for (i = 0; i < v3.size(); i++) sum1 += v3[i];
  }
  while (1) {
    if (v4.size() == 0) break;
    v4.pop_back();
    if (v5.size() == 0) break;
    v5.pop_back();
  }
  t = max(v4.size(), v5.size());
  if (v4.size() == t) {
    for (i = 0; i < v4.size(); i++) sum3 += v4[i];
  } else {
    for (i = 0; i < v4.size(); i++) sum3 += v5[i];
  }
  cout << min(sum1, sum3) << endl;
  return 0;
}
