#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int a[n];
  long long int e, o;
  e = o = 0;
  vector<long long int> even, odd;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      e++;
      even.push_back(a[i]);
    } else {
      odd.push_back(a[i]);
      o++;
    }
  }
  long long int x = max(e, o);
  long long int bt = -1;
  if (x == e) bt = 0;
  if (x == o) bt = 1;
  if (x == e && x == o) bt = 2;
  x -= min(e, o);
  x -= 1;
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  long long int ans = 0;
  if (bt == 0)
    for (long long int i = 0; i < x; i++) {
      ans += even[i];
    }
  if (bt == 1)
    for (long long int i = 0; i < x; i++) {
      ans += odd[i];
    }
  if (bt == 2) {
    long long int ans1, ans2;
    ans1 = ans2 = 0;
    for (long long int i = 0; i < x; i++) {
      ans1 += odd[i];
      ans2 += even[i];
    }
    ans = min(ans1, ans2);
  }
  cout << ans;
  return 0;
}
