#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, l = 0, r = 0, define = 0, ans = 0, sum = 0, z = 0, i = 0,
                  suka = 0;
  cin >> n;
  long long a[n];
  vector<int> v1;
  vector<int> v2;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      v1.push_back(a[i]);
    else
      v2.push_back(a[i]);
    define += a[i];
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  reverse(v1.begin(), v1.end());
  reverse(v2.begin(), v2.end());
  if (v1.size() > v2.size()) {
    while (i < v2.size() || z < v1.size()) {
      if (sum % 2 == 0 && z < v1.size()) {
        ans += v1[z];
        z++;
        sum++;
      } else if (i < v2.size()) {
        ans += v2[i];
        i++;
        sum++;
      }
      suka++;
      if (suka >= 1e5) {
        cout << define - ans;
        return 0;
      }
    }
  } else {
    while (i < v1.size() || z < v2.size()) {
      if (sum % 2 == 0 && z < v2.size()) {
        ans += v2[z];
        z++;
        sum++;
      } else if (i < v1.size()) {
        ans += v1[i];
        i++;
        sum++;
      }
      suka++;
      if (suka >= 1e5) {
        cout << define - ans;
        return 0;
      }
    }
  }
  cout << define - ans;
  return 0;
}
