#include <bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, greater<int> > pqo;
priority_queue<int, vector<int>, greater<int> > pqe;
int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  int r;
  while (n--) {
    int tmp;
    scanf("%d", &tmp);
    sum += tmp;
    if (tmp % 2)
      pqo.push(tmp);
    else
      pqe.push(tmp);
  }
  if (pqo.empty()) {
    if (pqe.empty()) {
      puts("0");
      return 0;
    } else {
      printf("%d\n", pqe.top());
      return 0;
    }
  } else if (pqe.empty()) {
    if (pqo.empty()) {
      puts("0");
      return 0;
    } else {
      printf("%d\n", pqo.top());
      return 0;
    }
  }
  if (pqo.top() < pqe.top()) {
    sum -= pqo.top();
    pqo.pop();
    r = 1;
  } else {
    sum -= pqe.top();
    pqe.pop();
    r = 0;
  }
  while (!pqo.empty() || !pqe.empty()) {
    if (r) {
      if (pqe.empty()) break;
      sum -= pqe.top();
      pqe.pop();
      r = 0;
    } else {
      if (pqo.empty()) break;
      sum -= pqo.top();
      pqo.pop();
      r = 1;
    }
  }
  printf("%d", sum);
  return 0;
}
