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