#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
int arr[2005];
int main() {
  scanf(" %d", &n);
  vector<int> odd, even;
  ll tot = 0LL;
  for (int i = 1; i <= n; ++i) {
    scanf(" %d", &arr[i]);
    tot += arr[i];
    if (arr[i] % 2) {
      odd.push_back(arr[i]);
    } else {
      even.push_back(arr[i]);
    }
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());
  reverse(odd.begin(), odd.end());
  reverse(even.begin(), even.end());
  if (even.size() < odd.size()) swap(even, odd);
  for (int x : odd) {
    tot -= x;
  }
  for (int i = 0; i < min((int)even.size(), (int)odd.size() + 1); ++i) {
    tot -= even[i];
  }
  printf("%lld\n", tot);
  return 0;
}
