#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int sx = 0;
    vector<int> v1, v2;
    for (int i = 0; i < n; i++) {
      int x = 0;
      cin >> x;
      sx = sx + x;
      if (x % 2 == 0)
        v2.push_back(x);
      else
        v1.push_back(x);
    }
    sort(v1.begin(), v1.end(), greater<int>());
    sort(v2.begin(), v2.end(), greater<int>());
    int n1 = v1.size();
    int n2 = v2.size();
    int sum = 0;
    if (n1 == n2)
      for (int i = 0; i < n1; i++) sum = sum + v1[i] + v2[i];
    else {
      if (n1 > n2) {
        for (int i = 0; i < n2; i++) sum = sum + v1[i] + v2[i];
        sum = sum + v1[n2];
      } else {
        for (int i = 0; i < n1; i++) sum = sum + v1[i] + v2[i];
        sum = sum + v2[n1];
      }
    }
    cout << sx - sum << endl;
  }
}
