#include <bits/stdc++.h>
using namespace std;
int n, k = 0, m = 0;
long long sum = 0;
vector<int> b, c;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0) {
      k++;
      b.push_back(x);
    } else {
      m++;
      c.push_back(x);
    }
  }
  if (k > m + 1) {
    for (int i = 0; i < k - m - 1; i++) {
      sum += b[i];
    }
    cout << sum;
    return 0;
  }
  if (k + 1 < m) {
    for (int i = 0; i < m - k - 1; i++) {
      sum += c[i];
    }
    cout << sum;
    return 0;
  }
  cout << "0";
  return 0;
}
