#include <bits/stdc++.h>
using namespace std;
long long int t, i, j, n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  vector<long long int> odd, even;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    if (x % 2 == 0) {
      even.push_back(x);
    } else {
      odd.push_back(x);
    }
  }
  sort(even.begin(), even.end());
  reverse(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  reverse(odd.begin(), odd.end());
  long long int index = min(even.size(), odd.size());
  long long int sum = 0;
  if (even.size() <= odd.size()) {
    for (long long int i = index + 1; i < odd.size(); i++) {
      sum += odd[i];
    }
  } else {
    for (long long int i = index + 1; i < even.size(); i++) {
      sum += even[i];
    }
  }
  cout << sum << endl;
  return 0;
}
