#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 3;
const int LG = 20;
const long long mod = 998244353;
const int INF = 2147483647;
const long long linf = 1e18;
const long double pi = acos(-1);
const long double EPS = 1e-10;
int n, used[N];
long long a[N];
long long play(vector<long long> a, int last) {
  vector<long long> b;
  int ok = -1;
  for (int i = 0; i < ((int)(a).size()); ++i) {
    if ((last % 2 != a[i] % 2) && ok == -1) {
      ok = a[i];
      continue;
    }
    b.push_back(a[i]);
  }
  if (((int)(a).size()) != ((int)(b).size())) return play(b, ok);
  long long sum = 0;
  for (int i = 0; i < ((int)(a).size()); ++i) sum += a[i];
  return sum;
}
int main() {
  scanf("%d", &n);
  vector<long long> x;
  for (int i = 1; i <= n; ++i) scanf("%lld", a + i), x.push_back(a[i]);
  long long ans1 = INF, ans2 = INF;
  for (int i = 1; i <= n; ++i) {
    if (a[i] & 1) {
      ans1 = a[i];
      break;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!(a[i] & 1)) {
      ans2 = a[i];
      break;
    }
  }
  ans1 = play(x, ans1), ans2 = play(x, ans2);
  printf("%lld\n", min(ans1, ans2));
}
