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