t=int(input())
l=list(map(int,input().split()))
even=[]
odd=[]
for w in l:
	if w%2==0:
		even.append(w)
	else:
		odd.append(w)
even=sorted(even)
odd=sorted(odd)
e,o=len(even),len(odd)
ans=0
if e==o or e-o==1 or e-o==-1:
	print(0)
elif e==0:
	for w in range(o-1):
		ans+=odd[w]
	print(ans)
elif o==0:
	for w in range(e-1):
		ans+=even[w]
	print(ans)
else:
	if e>o:
		for w in range(e-o-1):
			ans+=even[w]
	elif o>e:
		for w in range(o-e-1):
			ans+=odd[w]
	print(ans)