#include <bits/stdc++.h>
using namespace std;
int arr[2001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string str;
  int ne = 0, no = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] % 2 == 0)
      ne++;
    else
      no++;
  }
  sort(arr, arr + n);
  bool even;
  int j = n - 1;
  if (ne > no) {
    even = 0;
  } else
    even = 1;
  while (j >= 0) {
    if (even) {
      if (arr[j] % 2 == 1) {
        arr[j] = -1;
        even = 0;
        j = n - 1;
        continue;
      }
    } else {
      if (arr[j] % 2 == 0) {
        arr[j] = -1;
        even = 1;
        j = n - 1;
        continue;
      }
    }
    j--;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] > 0) ans += arr[i];
  }
  cout << ans;
}
