#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  vector<int> odd;
  vector<int> even;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2) {
      odd.push_back(arr[i]);
    } else {
      even.push_back(arr[i]);
    }
  }
  long long int ans = 0;
  int odd_l = odd.size();
  int even_l = even.size();
  if (even_l > odd_l) {
    int temp = even_l - odd_l - 1;
    sort(even.begin(), even.end());
    for (int i = 0; i < temp; i++) {
      ans += even[i];
    }
  } else {
    int temp = odd_l - even_l - 1;
    sort(odd.begin(), odd.end());
    for (int i = 0; i < temp; i++) {
      ans += odd[i];
    }
  }
  cout << ans << endl;
  return 0;
}
