#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return a > b; }
int main() {
  int a;
  while (scanf("%d", &a) != EOF) {
    int arr[a];
    int arr2[a];
    int m1 = 0;
    int m2 = 0;
    for (int i = 0; i < a; i++) {
      int temp;
      scanf("%d", &temp);
      if (temp % 2 == 0)
        arr[m1++] = temp;
      else
        arr2[m2++] = temp;
    }
    sort(arr, arr + m1, comp);
    sort(arr2, arr2 + m2, comp);
    if (m1 - m2 > -2 && m1 - m2 < 2)
      printf("0");
    else if (m1 == 0) {
      long long sum = 0;
      for (int i = 1; i < m2; i++) sum += (long long)arr2[i];
      printf("%I64d", sum);
    } else if (m2 == 0) {
      long long sum = 0;
      for (int i = 1; i < m1; i++) sum += (long long)arr[i];
      printf("%I64d", sum);
    } else if (m1 < m2) {
      long long sum = 0;
      int lol = m2 - m1 - 1;
      for (int i = (m2 - lol); i < m2; i++) {
        sum += (long long)arr2[i];
      }
      printf("%I64d", sum);
    } else {
      long long sum = 0;
      int lol = m1 - m2 - 1;
      for (int i = (m1 - lol); i < m1; i++) {
        sum += (long long)arr[i];
      }
      printf("%I64d", sum);
    }
    printf("\n");
  }
  return 0;
}
