#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
long long int p[N], c[N];
vector<long long int> odd1, eve1, odd2, eve2;
set<long long int> st;
long long int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, source;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2) {
      odd1.push_back(a[i]);
      odd2.push_back(a[i]);
    } else {
      eve1.push_back(a[i]);
      eve2.push_back(a[i]);
    }
  }
  sort(odd1.begin(), odd1.end());
  sort(odd2.begin(), odd2.end());
  sort(eve1.begin(), eve1.end());
  sort(eve2.begin(), eve2.end());
  long long int cnt = 0;
  long long int flag = 1;
  while (1) {
    if (odd1.size() > 0 && flag == 1) {
      odd1.pop_back();
      flag = 0;
    } else
      break;
    if (eve1.size() > 0 && flag == 0) {
      eve1.pop_back();
      flag = 1;
    } else
      break;
  }
  flag = 1;
  while (1) {
    if (eve2.size() > 0 && flag == 1) {
      eve2.pop_back();
      flag = 0;
    } else
      break;
    if (odd2.size() > 0 && flag == 0) {
      odd2.pop_back();
      flag = 1;
    } else
      break;
  }
  long long int ans1 = 0, ans2 = 0;
  if (odd1.size()) {
    for (auto i : odd1) ans1 += i;
  }
  if (eve1.size()) {
    for (auto i : eve1) ans1 += i;
  }
  if (odd2.size()) {
    for (auto i : odd2) ans2 += i;
  }
  if (eve2.size()) {
    for (auto i : eve2) ans2 += i;
  }
  cout << min(ans1, ans2);
  return 0;
}
