# your code goes here
n=int(input())
a=[int(x) for x in input().split()]
evens=[]
odds=[]
for i in a:
	if i%2==0:
		evens.append(i)
	else:
		odds.append(i)
evens=sorted(evens)
odds=sorted(odds)
if abs(len(evens)-len(odds))<=1:
	print(0)
else:
	if len(evens)>len(odds):
		rem=len(evens)-len(odds)-1
		print(sum(evens[:rem]))
	else:
		rem=len(odds)-len(evens)-1
		print(sum(odds[:rem]))