#include <bits/stdc++.h>
using namespace std;
vector<long long> even, odd;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    long long temp;
    cin >> temp;
    if (temp & 1)
      odd.push_back(temp);
    else
      even.push_back(temp);
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  int t = odd.size() - even.size();
  if (t < 0) t *= -1;
  if (t <= 1)
    cout << "0\n";
  else {
    long long ans = 0;
    if (odd.size() < even.size())
      for (int i = odd.size() + 1; i < even.size(); ++i) ans += even[i];
    else
      for (int i = even.size() + 1; i < odd.size(); ++i) ans += odd[i];
    cout << ans << '\n';
  }
  return 0;
}
