#include <bits/stdc++.h>
using namespace std;
int calc(vector<int> v, int n) {
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += v[i];
  }
  return sum;
}
int main() {
  int n, x;
  cin >> n;
  vector<int> odd, even;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x % 2) {
      odd.push_back(x);
    } else {
      even.push_back(x);
    }
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  int odd_len = odd.size();
  int even_len = even.size();
  int ans;
  if (odd_len == 0) {
    ans = calc(even, even_len - 1);
  } else if (even_len == 0) {
    ans = calc(odd, odd_len - 1);
  } else {
    int diff = even_len - odd_len;
    if (diff > 0) {
      ans = calc(even, diff);
    } else if (diff < 0) {
      ans = calc(odd, diff);
    } else {
      ans = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
