#include <bits/stdc++.h>

using namespace std;

int main() {

	ios::sync_with_stdio(false);
	//cin.tie(NULL);
	
	int n, x, sum;
	cin >> n;
	
	vector <int> vPar;
	vector <int> vImpar;
	
	sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if(x % 2 == 0)
			vPar.push_back(x);
		else
			vImpar.push_back(x);
		sum += x;
	}
	
	if (abs(vPar.size() - vImpar.size()) > 2) {
		cout << 0 << "\n";
		return 0;
	}
	
	sort(vPar.begin(), vPar.end());
	sort(vImpar.begin(), vImpar.end());
	int k = min(vImpar.size(), vPar.size());
	
	if(vPar.size() > 0) {
		sum -= vPar[0];
		vPar[0] = 0;
	} else if(vImpar.size() > 0){
		sum -= vImpar[0];
		vImpar[0] = 0;
	}
	
	for (int i = 0; i < k; i++) {
		sum -= vImpar[i];
		sum -= vPar[i];
	}
	
	if (vImpar.size() == k)
		sum -= vPar[k];
	else
		sum -= vImpar[k];
		
	cout << sum << "\n";
	
	
	
	return 0;
}