#include <bits/stdc++.h>
using namespace std;
const long long int p_mod = 9999999999999983;
const long double pi = 3.14159265358979323;
const long long int N = 1e6 + 9;
const long long int mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}
long long int powerk(long long int x, long long int y);
long long int a[N];
void solve() {
  long long int n, m = 0, flag = 0, t = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    t += a[i];
    if (a[i] & 1) m++;
  }
  flag = n - m;
  sort(a + 1, a + n + 1);
  if (flag > m)
    flag = m + 1;
  else if (m > flag)
    m = flag + 1;
  long long int o = 0, e = 0, sum = 0;
  for (int i = n; i >= 1; --i) {
    if (a[i] & 1) {
      if (m) sum += a[i], m--;
    } else {
      if (flag) sum += a[i], flag--;
    }
  }
  cout << t - sum;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
}
long long int powerk(long long int x, long long int y) {
  if (y == 0) return 1;
  if (y == 1) return x % mod;
  if (y & 1)
    return ((powerk((x * x) % mod, y / 2) % mod) * x) % mod;
  else
    return powerk((x * x) % mod, y / 2) % mod;
}
