#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) {
      odd = even + 1;
      for (int i = n - 1; i >= 0; i--) {
        if (odd > 0 && a[i] % 2 == 1) {
          sum -= a[i];
          odd--;
        } else if (even > 0 && a[i] % 2 == 0) {
          sum -= a[i];
          even--;
        }
      }
    } else if (odd < even) {
      even = odd + 1;
      for (int i = n - 1; i >= 0; i--) {
        if (odd > 0 && a[i] % 2 == 1) {
          sum -= a[i];
          odd--;
        } else if (even > 0 && a[i] % 2 == 0) {
          sum -= a[i];
          even--;
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
