#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int e = 0, o = 0;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      e++;
    else
      o++;
  }
  int c = min(e, o);
  int e1 = e, o1 = o;
  e = c;
  o = c;
  for (int i = n - 1; i > -1; i--) {
    if (a[i] % 2 == 0 && e != 0) {
      a[i] = 0;
      e--;
    }
    if (a[i] % 2 == 1 && o != 0) {
      a[i] = 0;
      o--;
    }
  }
  for (int i = n - 1; i > -1; i--)
    if (a[i] != 0) {
      if (a[i] % 2 == 0 && e1 != c || a[i] % 2 == 1 && o1 != c) {
        a[i] = 0;
        break;
      }
    }
  int ans = 0;
  for (int i = 0; i < n; i++) ans += a[i];
  cout << ans;
  return 0;
}
