#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> even, odd;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0)
      even.push_back(a[i]);
    else
      odd.push_back(a[i]);
  }
  int diff = abs((int)even.size() - (int)odd.size()) - 1;
  ll res = 0;
  if ((int)even.size() > (int)odd.size()) {
    sort(even.begin(), even.end());
    for (int i = 0; i < diff; i++) res += even[i];
  } else {
    sort(odd.begin(), odd.end());
    for (int i = 0; i < diff; i++) res += odd[i];
  }
  cout << res << '\n';
  return 0;
}
