#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> odd, even;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x & 1)
      odd.push_back(x);
    else
      even.push_back(x);
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  int oo = (int)odd.size(), ee = (int)even.size();
  while (true) {
    if (ee == 0) {
      odd.pop_back();
      break;
    }
    if (oo == 0) {
      even.pop_back();
      break;
    }
    if (odd[oo - 1] > even[ee - 1]) {
      odd.pop_back();
      oo--;
      if (oo == 0) {
        even.pop_back();
        break;
      }
      ee--;
      even.pop_back();
      if (ee == 0) {
        odd.pop_back();
        break;
      }
    } else {
      even.pop_back();
      ee--;
      if (ee == 0) {
        odd.pop_back();
        break;
      }
      oo--;
      odd.pop_back();
      if (oo == 0) {
        even.pop_back();
        break;
      }
    }
  }
  long long int sum = 0;
  for (int i = 0, end = odd.size(); i < end; i++) sum += odd[i];
  for (int i = 0, end = even.size(); i < end; i++) sum += even[i];
  printf("%lld\n", sum);
  return 0;
}
