#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed;
  cout.precision(10);
  ;
  int n;
  cin >> n;
  vector<long long> even, odd;
  long long se = 0ll, so = 0ll, co = 0, ce = 0;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a & 1) {
      odd.push_back(a);
      so += a;
      co++;
    } else
      even.push_back(a), se += 1, ce++;
  }
  if (abs(co - ce) < 2) {
    cout << 0;
    return 0;
  }
  sort(even.begin(), even.end());
  sort(odd.begin(), odd.end());
  long long ans = 0ll;
  if (co > ce) {
    int diff = co - ce - 1;
    for (long long i = 0; i < diff; i++) ans += odd[i];
  } else {
    int diff = ce - co - 1;
    for (long long i = 0; i < diff; i++) ans += even[i];
  }
  cout << ans << "\n";
  return 0;
}
