#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<int> a, b;
    int x;
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (x % 2) {
        a.push_back(x);
      } else
        b.push_back(x);
    }
    int len = abs((int)a.size() - (int)b.size());
    if (len == 0) {
      cout << "0" << endl;
    } else {
      sort(a.begin(), a.end());
      sort(b.begin(), b.end());
      int ans = 0;
      if (a.size() > b.size()) {
        for (int i = 0; i < len - 1; i++) ans += a[i];
      } else {
        for (int i = 0; i < len - 1; i++) {
          ans += b[i];
        }
      }
      cout << ans << endl;
    }
  }
}
