#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, odd = 0, even = 0, count = 0;
  long long int sum = 0, temp = 0;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    temp += arr[i];
    if (arr[i] % 2 == 0)
      even++;
    else
      odd++;
  }
  sort(arr, arr + n);
  if (odd == even || odd - even == 1 || even - odd == 1)
    cout << "0";
  else {
    if (odd > even && even != 0) {
      for (int i = 0; i < n; i++) {
        if ((arr[i] % 2) != 0) {
          sum = sum + arr[i];
          count++;
        }
        if (count == (odd - even - 1)) break;
      }
    }
    if (even == 0)
      sum = temp - arr[n - 1];
    else if (odd < even && odd != 0) {
      for (int i = 0; i < n; i++) {
        if ((arr[i] % 2) == 0) {
          sum = sum + arr[i];
          count++;
        }
        if (count == (even - odd - 1)) break;
      }
    }
    if (odd == 0) sum = temp - arr[n - 1];
    cout << sum;
  }
  return 0;
}
