#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) {
      int x = os - es - 2;
      for (int i = 0; i <= x; i++) {
        sum = sum + od[i];
      }
    } else {
      int x = es - os - 2;
      for (int i = 0; i <= x; i++) {
        sum = sum + ev[i];
      }
    }
    cout << sum << endl;
  }
}
