#include <bits/stdc++.h>
using namespace std;
int coun[100020];
vector<int> kase[100020], vec;
int travers(int u) {
  int chld = 0;
  for (int i = 0; i < kase[u].size(); i++) {
    chld += travers(kase[u][i]);
  }
  if (chld == 0 && coun[u] == 1) vec.push_back(u);
  if (coun[u]) return 0;
  return 1;
}
void jump() {
  vector<int> even, odd;
  int sum = 0, odds = 0, evens = 0, n, a;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> a;
    if (a & 1) {
      odds++;
      odd.push_back(a);
    } else {
      evens++;
      even.push_back(a);
    }
  }
  if (evens) sort(even.begin(), even.end());
  if (odds) sort(odd.begin(), odd.end());
  while (evens && odds) {
    even.pop_back();
    odd.pop_back();
    evens--;
    odds--;
  }
  if (odds < evens)
    even.pop_back();
  else if (evens < odds)
    odd.pop_back();
  for (int i = 0; i < even.size(); i++) sum += even[i];
  for (int i = 0; i < odd.size(); i++) sum += odd[i];
  cout << sum << endl;
}
void voidfun() {
  int cn = 0;
  while (1) {
    cn++;
    if (cn == 10) break;
  }
  jump();
}
void fun() {
  int cn = 0;
  for (int i = 0; i < 10; i++) {
    cn++;
  }
  voidfun();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  fun();
  return 0;
}
