#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, c = 0, nc = 0, k = 0, l = 1, sum = 0;
  vector<int> a;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j;
    a.push_back(j);
    if (j % 2 == 0) {
      c++;
    } else {
      nc++;
    }
  }
  k = abs(c - nc);
  if (k <= 1) {
    cout << "0" << endl;
  } else {
    sort(a.begin(), a.end());
    if (c < nc) {
      i = 0;
      while (l < k) {
        if (a[i] % 2 != 0) {
          l++;
          sum += a[i];
        }
      }
    } else {
      i = 0;
      while (l < k) {
        if (a[i] % 2 == 0) {
          l++;
          sum += a[i];
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
