#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ip;
  vector<int> e, o;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> ip;
    ans += ip;
    if (ip % 2 == 0) {
      e.push_back(ip);
    } else {
      o.push_back(ip);
    }
  }
  sort(e.rbegin(), e.rend());
  sort(o.rbegin(), o.rend());
  int l1 = e.size(), l2 = o.size();
  if (l1 == 0)
    ans -= o[0];
  else if (l2 == 0)
    ans -= e[0];
  else {
    int turn;
    int i1 = 0, i2 = 0;
    if (e[0] > o[0])
      turn = 0;
    else
      turn = 1;
    for (int i = 1; i <= 2 * min(l1, l2); i++) {
      if (turn % 2 == 0)
        ans -= e[i1++];
      else
        ans -= o[i2++];
      turn++;
    }
    if (l1 < l2) {
      ans -= o[i2++];
    } else if (l1 > l2) {
      ans -= e[i1++];
    }
  }
  cout << ans << "\n";
  return 0;
}
