#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<multiset<int, greater<int>>> s(2);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    s[0].insert(a);
    s[1].insert(a);
  }
  vector<int> a(2, sum);
  vector<bool> e = {true, false};
  for (int i = 0; i < 2; i++) {
    while (true) {
      bool f = false;
      for (auto &j : s[i]) {
        if (j % 2 == e[i]) {
          a[i] -= j;
          s[i].erase(s[i].find(j));
          e[i] = !e[i];
          f = true;
          break;
        }
      }
      if (!f) {
        break;
      }
    }
  }
  cout << min(a.front(), a.back());
  return 0;
}
