#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long sum = 0;
  int odd = 0, even = 0;
  cin >> n;
  int a[2010];
  vector<int> ve1, ve2;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] % 2) {
      odd++;
      ve1.push_back(a[i]);
    } else {
      even++;
      ve2.push_back(a[i]);
    }
  }
  sort(ve1.begin(), ve1.end());
  sort(ve2.begin(), ve2.end());
  if (abs(odd - even) <= 1)
    printf("0");
  else {
    if (odd > even) {
      int k = odd - even - 1;
      for (int i = 0; i < k; ++i) sum += ve1[i];
    } else {
      int k = even - odd - 1;
      for (int i = 0; i < k; ++i) sum += ve2[i];
    }
    printf("%lld\n", sum);
  }
}
