#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int power(long long int a, long long int b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    return power(a * a % mod, b / 2);
  } else
    return (a * power(a * a % mod, b / 2)) % mod;
}
vector<int> v[100001];
int main() {
  int n;
  cin >> n;
  int a[n];
  vector<int> v;
  vector<int> v1;
  long long int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum = sum + a[i];
    if (a[i] % 2 == 0)
      v.push_back(a[i]);
    else
      v1.push_back(a[i]);
  }
  if (v1.size() == 0) {
    long long int sum = 0;
    for (int i = 0; i < n - 1; ++i) {
      if (a[i] % 2 == 0) {
        sum = sum + a[i];
      }
    }
    cout << sum << '\n';
    return 0;
  }
  if (v.size() == 0) {
    long long int sum = 0;
    for (int i = 0; i < n - 1; ++i) {
      if (a[i] % 2 != 0) {
        sum = sum + a[i];
      }
    }
    cout << sum << '\n';
    return 0;
  }
  sort(v.begin(), v.end());
  sort(v1.begin(), v1.end());
  long long int del1 = 0, del2 = 0;
  int temp = v.size() - 1;
  for (int i = v1.size() - 1; i >= 0; --i) {
    if (temp == -1) {
      del1 = del1 + v1[i];
      break;
    }
    del1 = del1 + v1[i] + v[temp--];
  }
  del1 = sum - del1;
  temp = v1.size() - 1;
  for (int i = v.size() - 1; i >= 0; --i) {
    if (temp == -1) {
      del2 = del2 + v[i];
      break;
    }
    del2 = del2 + v1[i] + v[temp--];
  }
  del2 = sum - del2;
  long long int ans = min(del1, del2);
  cout << ans << '\n';
  return 0;
}
