#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt;
  cin >> cnt;
  long long a[cnt + 10];
  vector<long long> x, y;
  x.clear(), y.clear();
  for (int i = 1; i <= cnt; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      x.push_back(a[i]);
    else
      y.push_back(a[i]);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  int n = (int)x.size(), m = (int)y.size();
  long long sum1 = 0, sum2 = 0;
  int l = n, r = m, now = 1;
  while (l > 0 && r > 0) {
    if (now == 1)
      l--, now = 2;
    else
      r--, now = 1;
  }
  l--;
  for (int i = 0; i < l; i++) sum1 += x[i];
  for (int i = 0; i < r; i++) sum1 += y[i];
  l = n, r = m, now = 2;
  while (l > 0 && r > 0) {
    if (now == 1)
      l--, now = 2;
    else
      r--, now = 1;
  }
  r--;
  for (int i = 0; i < l; i++) sum2 += x[i];
  for (int i = 0; i < r; i++) sum2 += y[i];
  cout << min(sum1, sum2);
  return 0;
}
