#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v1, v2;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h % 2)
      v1.push_back(h);
    else
      v2.push_back(h);
  }
  int p1 = v1.size(), p2 = v2.size();
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  int i, j;
  if (p1 == p2) {
    i = 0;
    j = 0;
  } else if (p1 < p2) {
    i = 0;
    j = p2 - p1 - 1;
  } else {
    i = p1 - p2 - 1;
    j = 0;
  }
  long long res = 0;
  for (int k = 0; k < i; k++) res += v1[k];
  for (int k = 0; k < j; k++) res += v2[k];
  cout << res << endl;
}
