#include <bits/stdc++.h>
using namespace std;
int cnt[2];
int main() {
  int n, a[2100], ans = 0;
  bool flag = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i] % 2]++;
  }
  sort(a, a + n);
  for (int i = n - ((2 * min(cnt[0], cnt[1])) + 1) - 1; i >= 0; i--)
    ans += a[i];
  cout << ans << endl;
  return 0;
}
