#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc;
  long long n;
  cin >> n;
  long long a[n + 5];
  long long odd = 0, even = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1)
      odd++;
    else
      even++;
    sum += a[i];
  }
  sort(a, a + n);
  if (odd == even || abs(odd - even) == 1)
    cout << 0 << endl;
  else {
    if (odd > even) {
      long long cnt = even + 1;
      for (int i = n - 1; i >= 0 && cnt > 0; i++) {
        if (a[i] % 2 == 1) {
          sum -= a[i];
          cnt--;
        }
        if (cnt == 0) break;
      }
      cnt = even;
      for (int i = n - 1; i >= 0 && cnt > 0; i++) {
        if (a[i] % 2 == 0) {
          sum -= a[i];
          cnt--;
        }
        if (cnt == 0) break;
      }
    } else {
      long long cnt = odd + 1;
      for (int i = n - 1; i >= 0 && cnt > 0; i++) {
        if (a[i] % 2 == 0) {
          sum -= a[i];
          cnt--;
        }
        if (cnt == 0) break;
      }
      cnt = odd;
      for (int i = n - 1; i >= 0 && cnt > 0; i++) {
        if (a[i] % 2 == 1) {
          sum -= a[i];
          cnt--;
        }
        if (cnt == 0) break;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
