#include <bits/stdc++.h>
using namespace std;
long long n, a, a0, a1, mn = 99999999, sum, o;
string s;
vector<int> v0, v1;
map<string, int> mp;
set<char> st;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a % 2 == 0) {
      v0.push_back(a);
    } else {
      v1.push_back(a);
    }
  }
  a0 = v0.size();
  a1 = v1.size();
  if (v0.size() == v1.size() || v0.size() - 1 == v1.size() ||
      v1.size() - 1 == v0.size()) {
    cout << 0;
    return 0;
  }
  sort(v0.begin(), v0.end());
  sort(v1.begin(), v1.end());
  if (v0.size() == 0) {
    cout << v1[0];
    return 0;
  }
  if (v1.size() == 0) {
    cout << v0[0];
    return 0;
  }
  if (v0.size() > v1.size()) {
    for (int i = 0; i < v0.size() - v1.size(); ++i) {
      sum += v0[i];
    }
    cout << sum;
  } else {
    for (int i = 0; i < v1.size() - v0.size(); ++i) {
      sum += v1[i];
    }
    cout << sum;
  }
}
