#include <bits/stdc++.h>
using namespace std;
int main() {
  int n{};
  cin >> n;
  vector<int> a(n);
  int num_odd{}, num_even{};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      num_even++;
    else
      num_odd++;
  }
  sort(a.begin(), a.end());
  int sum{}, num_rem{};
  num_rem = max(num_odd, num_even) - min(num_odd, num_even) - 1;
  int i{};
  while (num_rem > 0) {
    if (num_odd > num_even) {
      if (a[i] % 2 != 0) {
        sum += a[i];
        num_rem--;
      }
    } else {
      if (a[i] % 2 == 0) {
        sum += a[i];
        num_rem--;
      }
    }
    i++;
  }
  cout << sum;
}
