#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n, greater<int>());
  vector<int> even, odd;
  for (int i = 0; i < n; i++) {
    if ((arr[i] % 2) == 0)
      even.push_back(arr[i]);
    else
      odd.push_back(arr[i]);
  }
  int leneven = even.size();
  int lenodd = odd.size();
  if (leneven == lenodd) cout << 0 << endl;
  int sum = 0;
  if (leneven > lenodd) {
    for (int i = lenodd; i < leneven; i++) {
      sum += even[lenodd];
    }
    cout << sum;
  }
  if (leneven < lenodd) {
    for (int i = leneven; i < lenodd; i++) {
      sum += even[leneven];
    }
    cout << sum;
  }
  return 0;
}
