#include <bits/stdc++.h>
using namespace std;
vector<long long> v1, v2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long total;
  cin >> total;
  for (long long i = 1; i <= total; i++) {
    long long val;
    cin >> val;
    if (val % 2 == 0)
      v1.push_back(val);
    else
      v2.push_back(val);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  long long temp = (long long)v1.size() - (long long)v2.size();
  temp = abs(temp);
  if (temp <= 1) {
    cout << 0 << endl;
  } else {
    long long sum = 0;
    if (v1.size() > v2.size()) {
      for (long long i = 0; i < temp - 1; i++) {
        sum += v1[i];
      }
    } else {
      for (long long i = 0; i < temp - 1; i++) {
        sum += v2[i];
      }
    }
    cout << sum << endl;
  }
}
