#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> odd, even;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x & 1)
      odd.push_back(x);
    else
      even.push_back(x);
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  if (odd.size() == even.size())
    cout << 0;
  else if (even.size() > odd.size()) {
    int sum = 0;
    for (int i = 0; i < even.size() - odd.size() - 1; i++) {
      sum += even[i];
    }
    cout << sum;
  } else {
    int sum = 0;
    for (int i = 0; i < odd.size() - even.size() - 1; i++) {
      sum += odd[i];
    }
    cout << sum;
  }
  return 0;
}
