#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<int> odd, even;
  for (int i = n - 1; i >= 0; i--) {
    if (v[i] % 2)
      odd.push_back(v[i]);
    else
      even.push_back(v[i]);
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  int ei = even.size() - 1;
  int oi = odd.size() - 1;
  if ((ei == oi + 1) || (oi == ei + 1) || (oi == ei)) {
    cout << 0 << "\n";
    return 0;
  }
  int prev = 0;
  while (true) {
    if (prev == 0) {
      int max_e = -1, max_o = -1;
      if (ei >= 0) max_e = even[ei];
      if (oi >= 0) max_o = odd[oi];
      if (max_e > max_o) {
        ei--;
        prev = 2;
      } else {
        oi--;
        prev = 1;
      }
    } else if (prev == 2 && oi >= 0) {
      oi--;
      prev = 1;
    } else if (prev == 1 && ei >= 0) {
      ei--;
      prev = 2;
    } else {
      break;
    }
    if (ei < 0 && oi < 0) break;
  }
  long long ans = 0;
  for (int i = 0; i <= ei; i++) ans += even[i];
  for (int i = 0; i <= oi; i++) ans += odd[i];
  cout << ans << "\n";
}
