#include <bits/stdc++.h>
using namespace std;
vector<int> vt;
vector<int> vt1;
int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int q;
    scanf("%d", &q);
    if (q % 2)
      vt.push_back(q);
    else
      vt1.push_back(q);
    sum += q;
  }
  sort(vt.begin(), vt.end());
  sort(vt1.begin(), vt1.end());
  int sum1 = 0;
  int ch = vt.size() - 1, ch1 = vt1.size() - 1;
  int cnt = 0;
  while (1) {
    if (cnt % 2 == 0 && ch < 0) break;
    if (cnt % 2 == 1 && ch1 < 0) break;
    if (cnt % 2 == 0) {
      sum1 += vt[ch];
      ch--;
      cnt++;
    } else {
      sum1 += vt1[ch1];
      ch1--;
      cnt++;
    }
  }
  if (ch >= 0) sum1 += vt[ch];
  if (ch1 >= 0) sum1 += vt1[ch1];
  printf("%d", sum - sum1);
}
