#include <bits/stdc++.h>
using namespace std;
int f(int key) {
  if (key < 0) {
    return key * -1;
  }
  return key;
}
int main() {
  int n, temp, maxx = 0, po = 0, pe = 0, len;
  bool isodd;
  cin >> n;
  vector<int> even;
  vector<int> odd;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    maxx = max(maxx, temp);
    if (temp % 2) {
      odd.push_back(temp);
    } else {
      even.push_back(temp);
    }
  }
  if (f(even.size() - odd.size()) <= 1) {
    cout << "0";
    return 0;
  }
  sort(even.begin(), even.end(), greater<int>());
  sort(odd.begin(), odd.end(), greater<int>());
  if (even.size() == 0) {
    int sum = 0;
    for (int i = 1; i < odd.size(); i++) {
      sum += odd[i];
    }
    cout << sum;
    return 0;
  }
  if (odd.size() == 0) {
    int sum = 0;
    for (int i = 1; i < even.size(); i++) {
      sum += even[i];
    }
    cout << sum;
    return 0;
  }
  if (even.size() > odd.size()) {
    int len = even.size() - odd.size(), sum = 0;
    for (int i = len; i < even.size(); i++) {
      sum += even[i];
    }
    cout << sum;
    return 0;
  } else {
    int len = odd.size() - even.size(), sum = 0;
    for (int i = len; i < odd.size(); i++) {
      sum += odd[i];
    }
    cout << sum;
    return 0;
  }
}
