#include <bits/stdc++.h>
using namespace std;
int main() {
  long long counter1 = 0, counter2 = 0, res = 0;
  int n;
  cin >> n;
  int counter = n, swp;
  long long* a = new long long[n];
  for (auto i = 0; i < n; i++) cin >> a[i];
  for (auto i = 0; i < n; i++) {
    if (a[i] % 2 == 0 or a[i] == 2)
      counter1++;
    else
      counter2++;
  }
  if (counter1 == counter2 or counter1 + 1 == counter2 or
      counter2 + 1 == counter1) {
    cout << 0;
    return 0;
  } else if (abs(counter1 - counter2) > 1) {
    sort(a, a + n);
    for (auto i = 0; i < abs(counter1 - counter2) - 1; i++) {
      res += a[i];
    }
    cout << res;
    return 0;
  }
  return 0;
}
