#include <bits/stdc++.h>
using namespace std;
vector<long long int> v2, v3, v4, v5;
int main() {
  long long int N, i, sum = 0;
  cin >> N;
  long long int a[N];
  for (i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      v2.push_back(a[i]);
      v4.push_back(a[i]);
    } else {
      v3.push_back(a[i]);
      v5.push_back(a[i]);
    }
  }
  sort(v2.begin(), v2.end());
  sort(v3.begin(), v3.end());
  if (v2.size() == v3.size())
    cout << "0" << endl;
  else if (v2.size() > v3.size()) {
    for (i = 0; i < v2.size() - (v3.size() + 1); i++) {
      sum += v2[i];
    }
    cout << sum << endl;
  } else {
    for (i = 0; i < v3.size() - (v2.size() + 1); i++) {
      sum += v3[i];
    }
    cout << sum << endl;
  }
  return 0;
}
