#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 18;
const long long maxx = (long long)1e6 + 6;
using namespace std;
long long n, sum = 0, inp;
vector<long long> even, odd;
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> inp;
    if (inp % 2 == 0)
      even.push_back(inp);
    else
      odd.push_back(inp);
  }
  long long e = even.size();
  long long o = odd.size();
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  if (abs(e - o) <= 1) {
    cout << "0" << endl;
    return 0;
  } else if (e == 0) {
    long long odd_sum = accumulate(odd.begin(), odd.end(), 0LL);
    cout << odd_sum - odd[0] << endl;
  } else if (o == 0) {
    long long even_sum = accumulate(even.begin(), even.end(), 0LL);
    cout << even_sum - even[0] << endl;
  } else {
    if (e > o && e != 0 && o != 0) {
      for (long long i = 0; i < e - (o + 1); i++) {
        sum += even[i];
      }
      cout << sum << endl;
      return 0;
    } else {
      for (long long i = 0; i < o - (e + 1); i++) {
        sum += even[i];
      }
      cout << sum << endl;
      return 0;
    }
  }
  return 0;
}
