#include <bits/stdc++.h>
using namespace std;
long long int removeDuplicates(long long int arr[], long long int n) {
  sort(arr, arr + n);
  if (n == 0 || n == 1) return n;
  long long int temp[n];
  long long int j = 0;
  for (long long int i = 0; i < n - 1; i++)
    if (arr[i] != arr[i + 1]) temp[j++] = arr[i];
  temp[j++] = arr[n - 1];
  for (long long int i = 0; i < j; i++) arr[i] = temp[i];
  return j;
}
long long int mostFrequent(long long int arr[], long long int n) {
  sort(arr, arr + n);
  long long int max_count = 1, res = arr[0], curr_count = 1;
  for (long long int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1])
      curr_count++;
    else {
      if (curr_count > max_count) {
        max_count = curr_count;
        res = arr[i - 1];
      }
      curr_count = 1;
    }
  }
  if (curr_count > max_count) {
    max_count = curr_count;
    res = arr[n - 1];
  }
  return res;
}
bool isPerfectSquare(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
long long int gcd(long long int a, long long int b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long int fSum(long long int arr[], long long int n, long long int sum) {
  unordered_map<long long int, long long int> prevSum;
  long long int res = 0;
  long long int currsum = 0;
  for (long long int i = 0; i < n; i++) {
    currsum += arr[i];
    if (currsum == sum) res++;
    if (prevSum.find(currsum - sum) != prevSum.end())
      res += (prevSum[currsum - sum]);
    prevSum[currsum]++;
  }
  return res;
}
int main() {
  long long int n, i, l, ans = 0, ans1 = 0, pos, j, k, x, y, z, c1 = 0, sum = 0,
                         c2 = 0, c3 = 0, c4 = 0, flag = 0;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) {
    if (a[i] % 2 == 0)
      c2++;
    else
      c1++;
  }
  sort(a, a + n);
  if (c1 == c2)
    sum = 0;
  else if (c1 == c2 + 1 || c2 == c1 + 1)
    sum = 0;
  else if (c1 == 0) {
    for (long long int i = 0; i < n - 1; i++) sum += a[i];
  } else if (c2 == 0) {
    for (long long int i = 0; i < n - 1; i++) sum += a[i];
  } else {
    x = min(c1, c2);
    y = max(c1, c2);
    k = c1 - (x + 1);
    for (long long int i = 0; i < n; i++) {
      if (y == c1) {
        if (a[i] % 2 == 1) {
          sum += a[i];
          k--;
          if (k < 1) break;
        }
      } else if (y == c2) {
        if (a[i] % 2 == 0) {
          sum += a[i];
          k--;
          if (k < 1) break;
        }
      }
    }
  }
  cout << sum << "\n";
}
