#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, evenele = 0, oddele = 0, s;
  cin >> n;
  vector<long int> even;
  vector<long int> odd;
  for (long int i = 0; i < n; i++) {
    cin >> s;
    if (s % 2 == 0) {
      even.push_back(s);
      evenele++;
    } else {
      oddele++;
      odd.push_back(s);
    }
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  if (evenele == oddele) {
    cout << 0 << endl;
  } else if (evenele > oddele) {
    long int ans = 0;
    for (long int i = 0; i < (evenele - (oddele + 1)); i++) ans = ans + even[i];
    cout << ans << endl;
  } else {
    long int ans = 0;
    for (long int i = 0; i < (oddele - (evenele + 1)); i++) ans = ans + odd[i];
    cout << ans << endl;
  }
}
