#include <bits/stdc++.h>
using namespace std;
int a[2010];
int main() {
  int n, odd = 0, even = 0, flag;
  long long sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] & 1)
      odd++;
    else
      even++;
  }
  sort(a, a + n);
  if (odd == even || abs(odd - even) == 1)
    cout << '0' << endl;
  else {
    if (odd > even) {
      flag = odd - even - 1;
      sum = 0;
      for (int i = 0; i < n; i++) {
        if (a[i] & 1) {
          sum += a[i];
          flag--;
        }
        if (flag == 0) break;
      }
    } else {
      flag = even - odd - 1;
      sum = 0;
      for (int i = 0; i < n; i++) {
        if ((a[i] & 1) != 1) {
          sum += a[i];
          flag--;
        }
        if (flag == 0) break;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
