#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int p[n];
  int d[n];
  for (int i = 0; i < n; i++) {
    p[i] = -1;
    d[i] = -1;
  }
  int ip = 0;
  int id = 0;
  for (int i = 0; i < n; i++) {
    int e;
    cin >> e;
    if (e % 2 == 0) {
      p[ip] = e;
      ip++;
    } else {
      d[id] = e;
      id++;
    }
  }
  if ((n % 2 == 0 && id == ip) || (n % 2 != 0 && id == ip + 1) ||
      (n % 2 != 0 && ip == id + 1)) {
    cout << 0 << endl;
    return 0;
  }
  size_t size = sizeof(p) / sizeof(p[0]);
  sort(p, p + size);
  size = sizeof(d) / sizeof(d[0]);
  sort(d, d + size);
  int e = 0;
  int k = 0;
  long long s = 0;
  if (ip > id + 1) {
    e = ip - id - 1;
    k = n - ip;
    for (int i = k; i < e; i++) {
      s += p[i];
    }
    cout << s << endl;
    return 0;
  }
  if (id > ip + 1) {
    e = id - ip - 1;
    k = n - id;
    for (int i = k; i < e; i++) {
      s += d[i];
    }
    cout << s << endl;
    return 0;
  }
}
