#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n;
  cin >> n;
  long int var;
  vector<long int> even, odd, even1, odd1;
  while (n--) {
    cin >> var;
    if (var % 2 == 0)
      even.push_back(var);
    else
      odd.push_back(var);
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  even1 = even;
  odd1 = odd;
  while (1) {
    if (even.empty())
      break;
    else
      even.pop_back();
    if (odd.empty())
      break;
    else
      odd.pop_back();
  }
  while (1) {
    if (odd1.empty())
      break;
    else
      odd1.pop_back();
    if (even1.empty())
      break;
    else
      even1.pop_back();
  }
  long int ans1, ans2;
  ans1 = ans2 = 0;
  for (long int i = 0; i < even.size(); i++) ans1 += even[i];
  for (long int i = 0; i < odd.size(); i++) ans1 += odd[i];
  for (long int i = 0; i < even1.size(); i++) ans2 += even1[i];
  for (long int i = 0; i < odd1.size(); i++) ans2 += odd1[i];
  cout << min(ans1, ans2);
  return 0;
}
