#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int e, o, y, sum = 0, x;
  vector<long long> ve, vo;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x % 2 == 0)
      ve.push_back(x);
    else
      vo.push_back(x);
  }
  e = ve.size();
  o = vo.size();
  sort(ve.begin(), ve.end());
  sort(vo.begin(), vo.end());
  y = e - o;
  if (abs(y) <= 1)
    cout << 0;
  else {
    if (y >= 2)
      for (int k = 0; k < y - 1; k++) sum += ve[k];
    else
      for (int k = 0; k < -1 - y; k++) sum += vo[k];
    cout << sum;
  }
}
