#include <bits/stdc++.h>
using namespace std;
long long a[2005];
vector<long long> Z;
vector<long long> F;
int main() {
  long long n, i, S = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    S += a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (i = 0; i < n; i++) {
    if (a[i] % 2 == 0)
      Z.push_back(a[i]);
    else
      F.push_back(a[i]);
  }
  i = 0;
  long long j = 0, k = 1, sum1 = 0, sum2 = 0;
  while (1) {
    if (k == 0) {
      if (i >= Z.size()) break;
      sum1 += Z[i];
      i++;
      k = 1;
    } else {
      if (j >= F.size()) break;
      sum1 += F[j];
      j++;
      k = 0;
    }
  }
  i = 0, j = 0, k = 0;
  while (1) {
    if (k == 0) {
      if (i >= Z.size()) break;
      sum2 += Z[i];
      i++;
      k = 1;
    } else {
      if (j >= F.size()) break;
      sum2 += F[j];
      j++;
      k = 0;
    }
  }
  long long maxi = max(sum1, sum2);
  cout << S - maxi;
  return 0;
}
