#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> e, o;
  int ne, no;
  for (int i = 0; i < n; i++) {
    int test;
    cin >> test;
    if (test % 2 == 0)
      e.push_back(test);
    else
      o.push_back(test);
  }
  ne = e.size();
  no = o.size();
  if (ne == no + 1 || no == ne + 1) {
    cout << 0;
    return 0;
  }
  int maxi, mini;
  maxi = max(ne, no);
  mini = min(ne, no);
  int t = maxi - mini - 1;
  bool f = false;
  if (maxi == ne) f = true;
  int sum = 0;
  for (int j = 0; j < t; j++) {
    if (f == true)
      sum = sum + e[j];
    else
      sum = sum + o[j];
  }
  cout << sum;
  return 0;
}
