#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[2005];
  int odd[2005], even[2005];
  int cnt1 = 0, cnt2 = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] & 1) {
      cnt1++;
      odd[cnt1] = a[i];
    } else {
      cnt2++;
      even[cnt2] = a[i];
    }
    ans += a[i];
  }
  sort(odd + 1, odd + 1 + cnt1, greater<int>());
  sort(even + 1, even + 1 + cnt2, greater<int>());
  long long m = 0;
  for (int i = 1;; i++) {
    if (i & 1) {
      if (i / 2 > cnt1) break;
      m += odd[i / 2];
    } else {
      if (i / 2 > cnt2) break;
      m += even[i / 2];
    }
  }
  long long mm = 0;
  for (int i = 1;; i++) {
    if (i & 1) {
      if (i / 2 > cnt2) break;
      mm += even[i / 2];
    } else {
      if (i / 2 > cnt1) break;
      mm += odd[i / 2];
    }
  }
  ans = min(ans - m, ans - mm);
  printf("%lld", ans);
  return 0;
}
