#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	ll k;
	cin>>n;
	vector<ll> e;
	vector<ll> o;
	for(int i=0;i<n;i++)
	{
		cin>>k;
		if(k%2==0)
		{
			e.push_back(k);
		}
		
		else
		o.push_back(k);
	}
	if(abs(e.size()-o.size())<=1)
	{
		cout<<"0";
		return(0);
	}
	sort(e.rbegin(),e.rend());
	sort(o.rbegin(),o.rend());
	k=min(e.size(),o.size());
	ll c=0;
	if(e.size()>o.size())
	{
		for(ll i=k+1;i<e.size();i++)
		{
			c+=e[i];
		}
	}
	else
	{
		for(ll i=k+1;i<e.size();i++)
		{
			c+=o[i];
		}
	}
	cout<<c;
}