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