#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a;
  vector<long long> c1, c2;
  bool f;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0)
      c2.push_back(a);
    else
      c1.push_back(a);
  }
  if (c1.size() - c2.size() == -1 || c1.size() - c2.size() == 1 ||
      c1.size() - c2.size() == 0)
    cout << 0;
  else {
    long long sum = 0;
    if (c2.size() > c1.size()) {
      sort(c2.begin(), c2.end());
      for (int i = 0; i < c2.size() - c1.size() - 1; i++) sum += c2[i];
      if (c1.size() == 0) sum += c2[c2.size() - 1];
      cout << sum;
    } else {
      sort(c1.begin(), c1.end());
      for (int i = 0; i < c1.size() - c2.size() - 1; i++) sum += c1[i];
      if (c2.size() == 0) sum += c1[c1.size() - 1];
      cout << sum;
    }
  }
}
