#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  vector<int> odd;
  vector<int> even;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] & 1)
      odd.push_back(arr[i]);
    else
      even.push_back(arr[i]);
  }
  sort(odd.rbegin(), odd.rend());
  sort(even.rbegin(), even.rend());
  int v = min(odd.size(), even.size());
  if (v + 1 >= max(odd.size(), even.size())) {
    cout << 0;
    return 0;
  }
  v++;
  int sum = 0;
  for (int i = 0; i < odd.size(); i++) {
    if (i < v) continue;
    sum += odd[i];
  }
  for (int i = 0; i < even.size(); i++) {
    if (i < v) continue;
    sum += even[i];
  }
  cout << sum << endl;
}
