#include <bits/stdc++.h>

using namespace std;

int main() {

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