#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *arr = new int[n];
  int odd = 0, even = 0;
  vector<int> oddArr;
  vector<int> evenArr;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0) {
      even++;
      evenArr.push_back(arr[i]);
    } else {
      odd++;
      oddArr.push_back(arr[i]);
    }
  }
  bool takeEven;
  int pick;
  bool takeNone = false;
  int total = 0;
  if (abs(even - odd) - 1 == 0 || even - odd == 0) {
    takeNone = true;
  } else {
    sort(evenArr.begin(), evenArr.end());
    sort(oddArr.begin(), oddArr.end());
  }
  if (!takeNone) {
    if (even - odd > 1) {
      pick = even - (odd + 1);
      for (int i = 0; i < pick; i++) {
        total += evenArr[i];
      }
    } else if (odd - even > 1) {
      pick = odd - (even + 1);
      for (int i = 0; i < pick; i++) {
        total += oddArr[i];
      }
    }
  }
  cout << total << "\n";
  return 0;
}
