#include <bits/stdc++.h>
const char endl = '\n';
int32_t main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  long long n, temp, O = 0, E = 0;
  std::vector<long long> odds;
  std::vector<long long> evens;
  std::cin >> n;
  for (long long i = 0; i < n; i++) {
    std::cin >> temp;
    if (temp % 2 == 1) {
      odds.push_back(temp);
      O++;
    } else {
      evens.push_back(temp);
      E++;
    }
  }
  std::sort(odds.begin(), odds.end());
  std::sort(evens.begin(), evens.end());
  long long diff = E - O;
  long long ans = 0;
  if (diff > 1) {
    for (long long i = 0; i < diff - 1; i++) {
      ans += evens[i];
    }
  }
  if (diff < -1) {
    diff *= -1;
    for (long long i = 0; i < diff - 1; i++) {
      ans += odds[i];
    }
  }
  std::cout << ans << endl;
}
