#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, countodd = 0, counteven = 0;
  cin >> n;
  long long int arr[n];
  vector<long long int> oddbaby, evenbaby;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0) {
      counteven++;
      evenbaby.push_back(arr[i]);
    } else {
      countodd++;
      oddbaby.push_back(arr[i]);
    }
  }
  if (oddbaby.size() != 0) sort(oddbaby.begin(), oddbaby.end());
  if (evenbaby.size() != 0) sort(evenbaby.begin(), evenbaby.end());
  if (countodd == counteven)
    cout << 0;
  else if (countodd == 0) {
    long long int minsum = 0;
    for (long long int i = 0; i < evenbaby.size() - 1; i++)
      minsum += evenbaby[i];
    cout << minsum;
  } else if (counteven == 0) {
    long long int minsum = 0;
    for (long long int i = 0; i < oddbaby.size() - 1; i++) minsum += oddbaby[i];
    cout << minsum;
  } else if (abs(countodd - counteven) == 1)
    cout << 0;
  else if (abs(countodd - counteven) > 1) {
    long long int x = abs(countodd - counteven);
    long long int maxi = max(countodd, counteven);
    long long int minsum = 0;
    if (maxi == countodd) {
      for (long long int i = 0; i < x; i++) minsum += oddbaby[i];
      cout << minsum;
    } else {
      for (long long int i = 0; i < x; i++) minsum += evenbaby[i];
      cout << minsum;
    }
  }
  return 0;
}
