#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
int a[N];
int t, n;
vector<int> odd;
vector<int> even;
int solve(int n, int a[]) {
  int res = 0;
  for (int i = 0; i < n; i++)
    if (a[i] % 2 == 0)
      even.push_back(a[i]);
    else
      odd.push_back(a[i]);
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  int d = odd.size() - even.size();
  if (abs(d) <= 1)
    return res;
  else if (d >= 2) {
    for (int i = 0; i < d - 1; i++) res += odd[i];
    return res;
  } else if (d <= -2) {
    for (int i = 0; i < -d - 1; i++) res += even[i];
    return res;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(n, a) << endl;
  return 0;
}
