#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, o = 0, e = 0;
  cin >> n;
  vector<int> v, vo, ve;
  for (long long int i = 0; i < n; i++) {
    int xx;
    cin >> xx;
    v.push_back(xx);
    if (xx % 2 == 0) {
      ve.push_back(xx);
      e++;
    } else {
      vo.push_back(xx);
      o++;
    }
  }
  if (o == e || o == (e + 1) || e == (o + 1))
    cout << 0 << endl;
  else if (o > e) {
    int xx = o - e, sum = 0;
    for (int i = 0; i < (xx - 1); i++) {
      sum += vo[i];
    }
    cout << sum << endl;
  } else if (e > o) {
    int xx = e - o, sum = 0;
    for (int i = 0; i < (xx - 1); i++) {
      sum += ve[i];
    }
    cout << sum << endl;
  }
  return 0;
}
