#include <bits/stdc++.h>
using namespace std;
long long int t, i, j, n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  vector<long long int> odd, even;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    if (x % 2 == 0) {
      even.push_back(x);
    } else {
      odd.push_back(x);
    }
  }
  sort(even.begin(), even.end());
  reverse(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  reverse(odd.begin(), odd.end());
  long long int i = 0;
  long long int j = 0;
  long long int prev = -1;
  while (true) {
    if (prev == -1) {
      if (i < even.size() && j < odd.size()) {
        if (even[i] <= odd[j]) {
          i++;
          prev = 0;
        } else {
          j++;
          prev = 1;
        }
      } else if (i < even.size()) {
        i++;
        prev = 0;
      } else {
        j++;
        prev = 1;
      }
    }
    if (prev == 0) {
      if (j >= odd.size()) {
        break;
      } else {
        j++;
        prev = 1;
      }
    } else if (prev == 1) {
      if (i >= even.size()) {
        break;
      } else {
        i++;
        prev = 0;
      }
    }
  }
  long long int sum = 0;
  while (i < even.size()) {
    sum += even[i];
    i++;
  }
  while (j < odd.size()) {
    sum += odd[j];
    j++;
  }
  cout << sum;
  return 0;
}
