#include <bits/stdc++.h>
int main() {
  int32_t numbers_count;
  std::string input;
  std::vector<int64_t> numbers;
  std::cin >> numbers_count;
  for (int32_t count = 0; count < numbers_count; count++) {
    std::cin >> input;
    numbers.push_back(std::stoi(input));
  }
  std::sort(numbers.rbegin(), numbers.rend());
  std::vector<int64_t> evens;
  std::vector<int64_t> odds;
  for (auto& number : numbers) {
    if (number % 2 == 0) {
      evens.push_back(number);
    } else {
      odds.push_back(number);
    }
  }
  std::vector<int64_t> sum;
  if (std::abs(static_cast<int64_t>(evens.size()) -
               static_cast<int64_t>(odds.size())) > 1) {
    size_t min_size = std::min(evens.size(), odds.size());
    sum.insert(sum.end(), evens.begin() + min_size, evens.end());
    sum.insert(sum.end(), odds.begin() + min_size, odds.end());
    std::sort(sum.rbegin(), sum.rend());
    int64_t result = 0;
    std::for_each(sum.begin() + 1, sum.end(),
                  [&](int64_t item) { result += item; });
    std::cout << result << std::endl;
  } else {
    std::cout << 0 << std::endl;
  }
  return 0;
}
