#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int o = 0;
  int e = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
    if (arr[i] % 2 == 0)
      e++;
    else
      o++;
  }
  int evenarr[e], oddarr[o];
  int k = 0, j = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] % 2 == 0) {
      evenarr[k] = arr[i];
      k++;
    } else {
      oddarr[j] = arr[i];
      j++;
    }
  }
  sort(evenarr, evenarr + e);
  sort(oddarr, oddarr + o);
  if (e > o) {
    while (o != -1) {
      sum = sum - evenarr[e - 1];
      e--;
      sum = sum - oddarr[o - 1];
      o--;
    }
    cout << sum;
  } else {
    while (e != -1) {
      sum = sum - evenarr[e - 1];
      e--;
      sum = sum - oddarr[o - 1];
      o--;
    }
    cout << sum;
  }
  return 0;
}
