#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  vector<long long int> a, b;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    if (x % 2)
      a.push_back(x);
    else
      b.push_back(x);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a.size() < b.size()) {
    long long int sum = 0;
    for (long long int i = 0; i < b.size() - (a.size() + 1); i++) sum += b[i];
    cout << sum;
  } else if (a.size() > b.size()) {
    long long int sum = 0;
    for (long long int i = 0; i < a.size() - (b.size() + 1); i++) sum += a[i];
    cout << sum;
  } else {
    cout << 0;
  }
}
