#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long sum1 = 0, sum2 = 0;
  long sum = 0;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0)
      sum1++;
    else if (arr[i] % 2 != 0)
      sum2++;
  }
  sort(arr.begin(), arr.end());
  if (sum1 < sum2) {
    for (int i = 0, j = 0; j < (abs(sum1 - sum2)) - 1; i++) {
      if (arr[i] % 2 != 0) {
        sum += arr[i];
        j++;
      }
    }
  } else if (sum1 > sum2) {
    for (int i = 0, j = 0; j < (abs(sum1 - sum2)) - 1; i++) {
      if (arr[i] % 2 == 0) {
        sum += arr[i];
        j++;
      }
    }
  }
  cout << sum;
  return 0;
}
