#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
vector<int> even, odd;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x % 2 == 0)
      even.push_back(x);
    else
      odd.push_back(x);
  }
  int a = even.size();
  int b = odd.size();
  if (a == b)
    cout << "0\n";
  else if (a < b) {
    sort(odd.begin(), odd.end());
    reverse(odd.begin(), odd.end());
    long long sum = 0;
    for (int i = a + 1; i < b; i++) {
      sum += odd[i];
    }
    cout << sum << '\n';
  } else {
    sort(even.begin(), even.end());
    reverse(even.begin(), even.end());
    long long sum = 0;
    for (int i = b + 1; i < a; i++) {
      sum += even[i];
    }
    cout << sum << '\n';
  }
  return 0;
}
