ll=lambda : list(map(int,input().split()))
n=int(input())
l=ll()
e,o=[],[]
total=sum(l)
for i in l:
	if i&1:
		o.append(i)
	else:
		e.append(i)
o.sort(reverse=True)
e.sort(reverse=True)
if abs(len(o)-len(e))<=1:
	print(0)
else:
	if(len(o)<len(e)):
		ans=sum(e[:len(o)+1])+sum(o)
	else:
		ans=sum(o[:len(e)+1])+sum(e)
	print(total-ans)