#include <bits/stdc++.h>
using namespace std;
int arr[2020];
vector<int> o;
vector<int> e;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int odd = 0, even = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] % 2)
      o.push_back(arr[i]);
    else
      e.push_back(arr[i]);
  }
  odd = o.size(), even = e.size();
  sort(o.begin(), o.end());
  sort(e.begin(), e.end());
  int num, sum = 0;
  if (odd >= even + 2) {
    num = odd - even - 1;
    for (int i = 0; i < num; i++) sum += o[i];
    cout << sum << "\n";
  } else if (odd <= even - 2) {
    num = even - odd - 1;
    for (int i = 0; i < num; i++) sum += e[i];
    cout << sum << "\n";
  } else
    cout << "0\n";
  return 0;
}
