#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> arr_even;
  vector<int> arr_odd;
  int even = 0, odd = 0;
  long long int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      even++;
      arr_even.push_back(a[i]);
    } else {
      odd++;
      arr_odd.push_back(a[i]);
    }
  }
  int diff = abs(even - odd);
  sort(arr_even.begin(), arr_even.end());
  sort(arr_odd.begin(), arr_odd.end());
  if (diff > 1) {
    if (even > odd) {
      for (int i = 0; i < diff - 1; ++i) sum += arr_even[i];
    } else if (odd > even) {
      for (int i = 0; i < diff - 1; ++i) sum += arr_odd[i];
    } else
      sum = 0;
  } else
    sum = 0;
  cout << sum << "\n";
  return 0;
}
