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