#include <bits/stdc++.h>
using namespace std;
long long t, n, i, j, k, b[200005], a[200005], x, m, l, r, mid, ans, s;
vector<long long> u, v;
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (x % 2)
      v.push_back(x);
    else
      u.push_back(x);
    s += x;
  }
  sort(u.begin(), u.end(), greater<long long>());
  sort(v.begin(), v.end(), greater<long long>());
  n = v.size();
  m = u.size();
  n = min(n, m);
  for (i = 0; i < n; i++) s -= u[i] + v[i];
  if (u.size() > v.size()) s -= u[i];
  if (u.size() < v.size()) s -= v[i];
  cout << s;
}
