#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> odd, even;
  for (int i = 0; i < n; i++) {
    if (arr[i] & 1)
      odd.push_back(arr[i]);
    else
      even.push_back(arr[i]);
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  if (odd.size() > even.size()) {
    for (int i = 0; i < odd.size() - even.size() - 1; i++) sum += odd[i];
  } else if (odd.size() == even.size())
    sum = 0;
  else {
    for (int i = 0; i < even.size() - odd.size() - 1; i++) sum += even[i];
  }
  cout << sum;
}
