#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, a[2005], b[2005], x = 0, y = 0, n, m, sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> m;
    if (m % 2 == 0) {
      a[x] = m;
      x++;
    } else {
      b[y] = m;
      y++;
    }
  }
  sort(a, a + x, greater<int>());
  sort(b, b + y, greater<int>());
  if (x == y || x + 1 == y || y + 1 == x) {
    cout << "0" << endl;
  } else {
    if (x > y) {
      for (i = y + 1; i < x; i++) {
        sum += a[i];
      }
    }
    if (x < y) {
      for (i = x + 1; i < y; i++) {
        sum += b[i];
      }
    }
    cout << sum << endl;
  }
}
