#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
priority_queue<int> q, q_, Q, Q_;
int a[2005];
int sum, sum_;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
    sum_ += a[i];
    if (a[i] & 1 == 1)
      q.push(a[i]), Q.push(a[i]);
    else
      q_.push(a[i]), Q_.push(a[i]);
  }
  while (!q.empty()) {
    int now = q.top();
    q.pop();
    sum -= now;
    if (q_.empty()) break;
    now = q_.top();
    q_.pop();
    sum -= now;
  }
  while (!Q_.empty()) {
    int now = Q_.top();
    Q_.pop();
    sum_ -= now;
    if (Q.empty()) break;
    now = Q.top();
    Q.pop();
    sum_ -= now;
  }
  printf("%d\n", min(sum, sum_));
  return 0;
}
