#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> odd;
  vector<long long> even;
  int o = 0;
  int e = 0;
  for (int x, i = 0; i < n; i++) {
    cin >> x;
    if (x % 2 == 0) {
      e++;
      even.push_back(x);
    } else {
      o++;
      odd.push_back(x);
    }
  }
  if (o == e - 1 || e == o - 1 || e == o) {
    cout << "0\n";
    return 0;
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.begin());
  long long sum = 0;
  if (o > e) {
    for (int i = 0; i < o - e - 1; i++) {
      sum += odd[i];
    }
  } else if (e > o) {
    for (int i = 0; i < e - o - 1; i++) {
      sum += even[i];
    }
  }
  cout << sum << "\n";
}
