#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a[2000], b[2000], c[2000], t = 0, s = 0, m = 0, sum = 0, i,
                                              j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      b[t] = a[i];
      t++;
    } else {
      c[s] = a[i];
      s++;
    }
  }
  if (s == 0) {
    for (i = 0; i < t; i++)
      if (b[i] > m) m = b[i];
    for (i = 0; i < t; i++) sum = sum + b[i];
    sum = sum - m;
    cout << sum << endl;
    goto loop;
  }
  if (t == 0) {
    for (i = 0; i < s; i++)
      if (c[i] > m) m = c[i];
    for (i = 0; i < s; i++) sum = sum + c[i];
    sum = sum - m;
    cout << sum << endl;
    goto loop;
  }
  if (s == t) {
    cout << 0 << endl;
    goto loop;
  }
  if (s == t - 1 || s == t + 1) {
    cout << 0 << endl;
    goto loop;
  }
  if (s > t + 1) {
    t = t + 1;
    while (t--) {
      for (i = 0; i < s; i++)
        if (c[i] > m) {
          m = c[i];
          sum = i;
        }
      for (j = 0; j < s; j++) {
        if (j < sum)
          c[j] = c[j];
        else
          c[j] = c[j + 1];
      }
      s--;
    }
    sum = 0;
    for (i = 0; i < s; i++) {
      sum = sum + c[i];
    }
    cout << sum << endl;
    goto loop;
  }
  if (t > s + 1) {
    s = s + 1;
    while (s--) {
      for (i = 0; i < t; i++)
        if (b[i] > m) {
          m = b[i];
          sum = i;
        }
      for (j = 0; j < t; j++) {
        if (j < sum)
          b[j] = b[j];
        else
          b[j] = b[j + 1];
      }
      t--;
    }
    sum = 0;
    for (i = 0; i < t; i++) {
      sum = sum + b[i];
    }
    cout << sum << endl;
    goto loop;
  }
loop:;
}
