#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> arr;
  vector<int> even_nums;
  vector<int> odd_nums;
  int even = 0, odd = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    arr.push_back(a);
    if (a % 2) {
      even++;
      even_nums.push_back(a);
    } else {
      odd++;
      odd_nums.push_back(a);
    }
    sum += a;
  }
  if (odd == 0 || even == 0) {
    cout << sum - *max_element(arr.begin(), arr.end());
    return 0;
  }
  if (abs(even - odd) <= 1)
    cout << 0;
  else {
    sort(odd_nums.begin(), odd_nums.end());
    sort(even_nums.begin(), even_nums.end());
    if (odd > even) {
      int s = 0;
      for (int i = 0; i < odd - even; i++) s += odd_nums[i];
      cout << s;
      return 0;
    } else {
      int s = 0;
      for (int i = 0; i < even - odd; i++) s += even_nums[i];
      cout << s;
      return 0;
    }
  }
  return 0;
}
