#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void Int(T &n) {
  n = 0;
  int f = 1;
  register int ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
template <typename T>
T gcd(T a, T b) {
  return !b ? a : gcd(b, a % b);
}
template <typename T>
inline void umin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void umax(T &a, T b) {
  a = a > b ? a : b;
}
template <typename T, typename W>
inline void Int(T &x, W &y) {
  Int(x), Int(y);
}
template <typename T, typename W, typename Q>
void Int(T &x, W &y, Q &z) {
  Int(x, y), Int(z);
}
const int N = 1e5 + 7;
const int inf = 1e9 + 7;
int n, a[N];
int process(int foo, int tot) {
  set<int> st[2];
  for (int i = 1; i <= n; ++i) {
    st[a[i] % 2].insert(a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    if (st[foo].empty()) {
      return tot;
    }
    tot -= *st[foo].rbegin();
    st[foo].erase(*st[foo].rbegin());
    foo ^= 1;
  }
  return tot;
}
int solve() {
  Int(n);
  for (int i = 1; i <= n; ++i) Int(a[i]);
  int tot = 0;
  for (int i = 1; i <= n; ++i) {
    tot += a[i];
  }
  printf("%d\n", min(process(0, tot), process(1, tot)));
  return 0;
}
int main() {
  int tests = 1, CaseNo = 0;
  while (tests--) {
    solve();
  }
  return 0;
}
