#include <bits/stdc++.h>
using namespace std;
int cnt[1000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int arr[n];
  int odd = 0, even = 0;
  vector<int> O, E;
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0) {
      E.push_back(arr[i]);
      even++;
    } else {
      O.push_back(arr[i]);
      odd++;
    }
  }
  int inter = min(odd, even);
  sort(O.begin(), O.end());
  sort(E.begin(), E.end());
  odd -= inter;
  even -= inter;
  if (odd > even) odd--;
  if (even > odd) even--;
  long long ans = 0;
  for (auto a : O) {
    if (odd == 0) break;
    ans += a;
    odd--;
  }
  for (auto a : E) {
    if (even == 0) break;
    ans += a;
    even--;
  }
  cout << ans << endl;
  return 0;
}
