#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, s = 0, i, x, o[20009], e[20009], l1 = 0, l2 = 0, l;
  cin >> t;
  for (i = 1; i <= t; i++) {
    cin >> x;
    if (x % 2 == 0)
      e[++l1] = x;
    else
      o[++l2] = x;
  }
  sort(e + 1, e + l1 + 1);
  sort(o + 1, o + l1 + 1);
  if (abs(l1 - l2) <= 1)
    cout << "0";
  else {
    if (l1 >= l2) {
      l = l1 - l2;
      for (i = 1; i < l; i++) s = s + e[i];
      cout << s;
    } else {
      l = l2 - l1;
      for (i = 1; i < l; i++) s = s + o[i];
      cout << s;
    }
  }
}
