#include <bits/stdc++.h>
using namespace std;
const long long N = 2020;
long long Try(vector<long long>& v1, vector<long long>& v2);
long long a[N];
vector<long long> v[2];
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++)
    scanf("%I64d", a + i), v[a[i] & 1].push_back(a[i]);
  for (long long k : {0, 1}) sort(v[k].begin(), v[k].end());
  cout << min(Try(v[0], v[1]), Try(v[1], v[0]));
}
long long Try(vector<long long>& v1, vector<long long>& v2) {
  long long Turn = 1;
  while (true) {
    vector<long long>& v3 = Turn ? v1 : v2;
    if (v3.empty()) break;
    v3.pop_back();
    Turn = !Turn;
  }
  long long Sum = 0;
  for (auto x : v1) Sum += x;
  for (auto x : v2) Sum += x;
  return Sum;
}
