#include <bits/stdc++.h>
using namespace std;
int q, n, m, ans;
int a[2005], b[2005];
int main() {
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0) {
      a[n] = x;
      n++;
    } else {
      b[m] = x;
      m++;
    }
  }
  if (abs(m - n) <= 1) {
    cout << 0;
    return 0;
  }
  sort(a, a + n);
  sort(b, b + n);
  if (m > n) {
    int x = q - 2 * min(n, m) - 1;
    int i = 0;
    while (x > 0) {
      ans += b[i];
      x--;
      i++;
    }
    cout << ans;
  } else {
    int i = 0;
    int x = q - min(n, m) - 1;
    while (x > 0) {
      ans += a[i];
      x--;
      if (x > 0) ans += b[i];
      x--;
      i++;
    }
    cout << ans;
  }
  return 0;
}
