#include <bits/stdc++.h>
using namespace std;
int make_positive(int a) { return a > 0 ? a : a * -1; }
int main(void) {
  int number;
  int temp;
  scanf("%d", &number);
  vector<int> even;
  vector<int> odd;
  for (int i = 0; i < number; i++) {
    scanf("%d", &temp);
    if (!(temp % 2)) {
      even.push_back(temp);
    } else {
      odd.push_back(temp);
    }
  }
  if (even.size() == odd.size() ||
      (even.size() - 1 == odd.size() || odd.size() - 1 == even.size())) {
    printf("0\n");
    return 0;
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  int limit = make_positive(even.size() - odd.size()) - 1;
  long long sum = 0;
  for (int i = 0; i < limit; i++) {
    if (even.size() > odd.size()) {
      sum += even[i];
    } else {
      sum += odd[i];
    }
  }
  printf("%d\n", sum);
  return 0;
}
