#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, e[2005] = {0}, o[2005] = {0}, l = 0, r = 0;
  cin >> n;
  long long suml = 0, sumr = 0;
  int even = 0, odd = 0;
  bool firsteven = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i == 0 && a % 2 != 0) firsteven = false;
    if (a % 2 == 0) {
      even += 1;
      e[l] = a;
      l += 1;
      suml += a;
    } else {
      odd += 1;
      o[r] = a;
      r += 1;
      sumr += a;
    }
  }
  int t = even - odd;
  if (firsteven == true)
    even -= 1;
  else
    odd -= 1;
  int s = abs(even - odd);
  if (s == 0 || t == 0)
    cout << 0;
  else if (even >= odd) {
    long long gege = 0;
    for (int i = 0; i < s; i++) {
      gege += e[i];
    }
    cout << suml - gege << endl;
  } else {
    long long gege = 0;
    for (int i = 0; i < s; i++) {
      gege += o[i];
    }
    cout << sumr - gege << endl;
  }
  return 0;
}
