#include <bits/stdc++.h>
using namespace std;
int a[2005], b[2005], c[2005];
int main() {
  int n, i, d = 0, j = 0, bsum = 0, csum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      b[d] = a[i];
      d++;
    } else {
      c[j] = a[i];
      j++;
    }
  }
  sort(c, c + j);
  sort(b, b + d);
  if (fabs(d - j) == 1 || d == j)
    cout << "0" << endl;
  else {
    if (d > j) {
      for (i = 0; i < d - j - 1; i++) {
        bsum += b[i];
      }
      cout << bsum;
      cout << endl;
    } else {
      for (i = 0; i < j - d - 1; i++) csum += c[i];
      cout << csum;
      cout << endl;
    }
  }
  return 0;
}
