#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ch = 0, nec = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0)
      ch++;
    else
      nec++;
  }
  if (abs(nec - ch) <= 1) {
    cout << 0;
  }
  if (ch - nec > 1) {
    int s = 0, t = 0;
    for (int i = 0; i < n; i--) {
      if (a[i] % 2 == 0) {
        s += a[i];
        t++;
      }
      if (t == ch - 1) break;
    }
    cout << s;
  }
  if (nec - ch > 1) {
    int s = 0, t = 0;
    for (int i = 0; i < n; i--) {
      if (a[i] % 2 == 1) {
        s += a[i];
        t++;
      }
      if (t == nec - 1) break;
    }
    cout << s;
  }
}
