#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, aux, j, c, y, s, S;
  cin >> n;
  int v[n];
  int w[n];
  int w1[n];
  c = 0;
  y = 0;
  s = 0;
  S = 0;
  for (i = 0; i < n; i++) cin >> v[i];
  for (i = 0; i < n; i++) {
    if (v[i] % 2 == 0) {
      w[c] = v[i];
      c++;
    } else {
      w1[y] = v[i];
      y++;
    }
  }
  if (c == y || c + 1 == y || y + 1 == c)
    cout << "0" << endl;
  else if (c == y + 2)
    cout << w1[0] << endl;
  else if (y == c + 2)
    cout << w[0] << endl;
  else {
    if (c < y) {
      if (c == 1)
        s = y - c - 1;
      else
        s = y - c;
      for (i = 0; i < s; i++) S += w1[i];
      cout << S << endl;
    }
    if (y < c) {
      if (y == 1)
        s = c - y - 1;
      else
        s = c - y;
      for (i = 0; i <= s; i++) S += w[i];
      cout << S << endl;
    }
  }
}
