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