#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum;
  cin >> n;
  int arr[n + 5];
  vector<int> od, ev;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0)
      od.push_back(arr[i]);
    else
      ev.push_back(arr[i]);
  }
  sort(od.begin(), od.end());
  sort(ev.begin(), ev.end());
  int os = od.size();
  int es = ev.size();
  if (os == es || abs(os - es) == 1) {
    cout << "0" << endl;
  } else {
    sum = 0;
    if (os > es) {
      for (int i = os - 1; i >= 1; i--) {
        sum = sum + arr[i];
      }
    } else {
      for (int i = es - 1; i >= 1; i--) {
        sum = sum + arr[i];
      }
    }
    cout << sum << endl;
  }
  cout << endl;
}
