#include <bits/stdc++.h>
using namespace std;
int n, x, ans, yyy;
vector<int> v1, v2;
inline int read() {
  int x = 0;
  bool sign = false;
  char alpha = 0;
  while (!isdigit(alpha)) sign |= alpha == '-', alpha = getchar();
  while (isdigit(alpha))
    x = (x << 1) + (x << 3) + (alpha ^ 48), alpha = getchar();
  return sign ? -x : x;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    x = read();
    x & 1 ? v1.push_back(x) : v2.push_back(x);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  if (v1.size() == 0)
    for (int i = 0; i < v2.size() - 1; i++) ans += v2[i];
  else if (v2.size() == 0)
    for (int i = 0; i < v1.size() - 1; i++) ans += v1[i];
  else if (v1.size() - 1 > v2.size())
    for (int i = 0; i < v1.size() - v2.size() - 1; i++) ans += v1[i];
  else if (v1.size() < v2.size() - 1)
    for (int i = 0; i < v2.size() - v1.size() - 1; i++) ans += v2[i];
  printf("%d\n", ans);
  return 0;
}
