#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> itRS) {}
template <typename T, typename... Args>
void err(istream_iterator<string> itRS, T a, Args... args) {
  cerr << *itRS << " = " << a << '\n';
  err(++itRS, args...);
}
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
map<long long int, vector<pair<int, int>>> v;
const int MOD = 1000000007;
int T[10001];
int main() {
  int n;
  cin >> n;
  int a[n];
  vector<int> o, e;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 != 0) {
      o.push_back(a[i]);
    } else {
      e.push_back(a[i]);
    }
  }
  sort(o.begin(), o.end());
  sort(e.begin(), e.end());
  int diff = o.size() - e.size();
  if (abs(diff) <= 1) {
    cout << 0 << '\n';
  } else {
    long long int sum = 0;
    if (o.size() < e.size()) {
      for (int i = 0; i < o.size() + 1; i++) {
        sum = sum + e[i];
      }
    } else {
      for (int i = 0; i < e.size() + 1; i++) {
        sum = sum + o[i];
      }
    }
    cout << sum << '\n';
  }
  return 0;
}
