#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[2005], ans = 0;
  vector<int> odd;
  vector<int> even;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if ((a[i] % 2) == 0)
      even.push_back(a[i]);
    else
      odd.push_back(a[i]);
  }
  sort(odd.rbegin(), odd.rend());
  sort(even.rbegin(), even.rend());
  if (odd.size() > even.size())
    for (int i = even.size() + 1; i < odd.size(); i++) ans += odd[i];
  else
    for (int i = odd.size() + 1; i < even.size(); i++) ans += even[i];
  cout << ans << endl;
  return 0;
}
