#include <bits/stdc++.h>
long int sort(long int array[], int x, int y);
int main(void) {
  int i, j, k, n, odd = 0, even = 0;
  scanf("%d", &n);
  long int result, array[n], odds[n], evens[n],
      max = -1, max1 = -1, min = 10000000, min1 = 10000000, total = 0,
      total1 = 0;
  for (i = 0, j = 0, k = 0; i < n; i++) {
    scanf("%d", &array[i]);
    if (!(array[i] & 1)) {
      even++;
      min = min < array[i] ? min : array[i];
      max = max < array[i] ? array[i] : max;
      evens[j] = array[i];
      total += array[i];
      j++;
    } else {
      odd++;
      min1 = min1 < array[i] ? min1 : array[i];
      max1 = max1 < array[i] ? array[i] : max1;
      odds[k] = array[i];
      total1 += array[i];
      k++;
    }
  }
  if (odd == even + 1 || even == odd + 1 || even == odd)
    printf("%d\n", 0);
  else if (!(odd))
    printf("%ld\n", total - max);
  else if (!(even))
    printf("%ld\n", total1 - max1);
  else {
    if (odd > even)
      result = sort(odds, odd - even - 1, odd);
    else
      result = sort(evens, even - odd - 1, even);
    printf("%ld\n", result);
  }
  return 0;
}
long int sort(long int array[], int x, int y) {
  int i, j, k = 0, pos;
  long int result = 0;
  for (i = 0; i < y; i++) {
    if (array[i] != -1) pos = i;
    for (j = 0; j < y; j++) {
      if (array[j] != -1 && i != j) pos = array[j] > array[pos] ? pos : j;
    }
    result += array[pos];
    array[pos] = -1;
    k++;
    if (k == x) return result;
  }
}
