#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, temp, i;
  cin >> n;
  int even[n], odd[n], evenlen = 0, oddlen = 0;
  for (i = 0; i < n; i++) {
    cin >> temp;
    if (temp % 2 == 0) {
      even[evenlen++] = temp;
    } else {
      odd[oddlen++] = temp;
    }
  }
  long long ans = 0;
  sort(even, even + evenlen);
  sort(odd, odd + oddlen);
  int remove = abs(evenlen - oddlen);
  if (oddlen > evenlen) {
    --remove;
    for (i = 0; i < remove; i++) ans += odd[i];
  } else if (oddlen < evenlen) {
    --remove;
    for (i = 0; i < remove; i++) ans += even[i];
  }
  cout << ans << endl;
  return 0;
}
