#include <bits/stdc++.h>
using namespace std;
int cmp(int a, int b) { return (a > b); }
int main() {
  int n;
  cin >> n;
  int i;
  int a[n];
  int jishu[n];
  int oushu[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n, cmp);
  int count = 0;
  int count1 = 0;
  int sum = 0;
  int k = 0, j = 0;
  for (i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      count++;
      oushu[k++] = a[i];
    } else {
      count1++;
      jishu[j++] = a[i];
    }
  }
  if (count == count1 || count - count1 == 1 || count1 - count == 1) {
    cout << "0";
  } else if (count - count1 > 1) {
    for (i = count1 + 1; i < count; i++) sum += oushu[i];
    cout << sum;
  } else {
    for (i = count + 1; i < count1; i++) sum += jishu[i];
    cout << sum;
  }
}
