#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n], i, j;
  vector<int> o, e;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] & 1)
      o.push_back(a[i]);
    else
      e.push_back(a[i]);
  }
  int os = o.size(), es = e.size();
  sort(e.begin(), e.end());
  sort(o.begin(), o.end());
  if (abs(os - es) <= 1)
    cout << "0\n";
  else {
    if (os > es) {
      cout << accumulate(o.begin(), o.begin() + (os - es) - 1, 0) << "\n";
    } else
      cout << accumulate(e.begin(), e.begin() + (es - os) - 1, 0) << "\n";
  }
}
