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