#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, a[2005], ji = 0, o = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i] = x;
    if (x & 1)
      ji++;
    else
      o++;
  }
  if (abs(ji - o) <= 1)
    cout << 0;
  else {
    if (ji < o) {
      int t = o - ji - 1, sum = 0, cou = 0;
      sort(a, a + n);
      for (int i = 0; cou < t; ++i)
        if (!(a[i] & 1)) sum += a[i], cou++;
      cout << sum;
    } else {
      int t = ji - o - 1, sum = 0, cou = 0;
      sort(a, a + n);
      for (int i = 0; cou < t; ++i)
        if (a[i] & 1) sum += a[i], cou++;
      cout << sum;
    }
  }
  return 0;
}
