#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int maxn = 2e6 + 7;
int judge(vector<int> v1, vector<int> v2) {
  int i = 0, j = 0;
  for (int k = 0;; k++) {
    if (k % 2 == 0) {
      if (i >= v1.size()) break;
      i++;
    } else {
      if (j >= v2.size()) break;
      j++;
    }
  }
  int ans = 0;
  for (; i < v1.size(); i++) {
    ans += v1[i];
  }
  for (; j < v2.size(); j++) {
    ans += v2[j];
  }
  return ans;
}
int main() {
  int n;
  while (cin >> n) {
    vector<int> odd, even;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      if (a % 2)
        odd.push_back(a);
      else
        even.push_back(a);
    }
    sort(odd.begin(), odd.end());
    sort(even.begin(), even.end());
    int ans = INF;
    ans = min(judge(odd, even), judge(even, odd));
    cout << ans << endl;
  }
  return 0;
}
