#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> m;
vector<int> m2;
int main() {
  int ch = 0, neche = 0;
  cin >> n;
  int a;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a % 2 == 0)
      m2.push_back(a);
    else
      m.push_back(a);
  }
  ch = m2.size();
  neche = m.size();
  sort(m.begin(), m.end());
  sort(m2.begin(), m2.end());
  while (!m.empty() && !m2.empty()) {
    m.pop_back();
    m2.pop_back();
  }
  if (ch > neche && !m2.empty())
    m2.pop_back();
  else if (neche > ch && !m.empty())
    m.pop_back();
  int sum = 0;
  for (int i = 0; i < m.size(); ++i) sum += m[i];
  for (int i = 0; i < m2.size(); ++i) sum += m2[i];
  cout << sum;
  return 0;
}
