#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = (1e18);
const long double PI = 4 * atan((long double)1);
int MAX = MOD;
void array_debug(vector<long long> ar) {
  for (auto x : ar) cout << x << ' ';
  cout << '\n';
}
long long power(long long x, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n & 1) result = (result * x) % MOD;
    x = (x * x) % MOD;
    n >>= 1;
  }
  return result % MOD;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  long long n, ps = 0;
  cin >> n;
  vector<long long> e, o;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    ps += x;
    if (x & 1)
      o.push_back(x);
    else
      e.push_back(x);
  }
  sort(o.rbegin(), o.rend());
  sort(e.rbegin(), e.rend());
  if (!o.size()) {
    cout << ps - e.back();
    return 0;
  }
  if (!e.size()) {
    cout << ps - o.back();
    return 0;
  }
  long long sum = ps;
  long long rte = min(e.size(), o.size());
  for (long long i = 0; i < rte; i++) sum -= (o[i] + e[i]);
  if (o.size() > rte) sum -= o[rte];
  if (e.size() > rte) sum -= o[rte];
  cout << sum;
}
