
k=int(input())
l=list(map(int,input().split()))
ev1=0
ev=[]
ed=[]
for i in range(k):
	if l[i]%2==0:
		ev1+=1
		ev.append(l[i])
	else:
		ed.append(l[i])
if abs(len(ev)-len(ed))==1 or abs(len(ev)-len(ed))==0:
	print(0)
	exit()
else:
	ev.sort()
	ed.sort()
	dif=len(ev)-len(ed)
	if dif>0:
		print(sum(ev[:abs(dif)-1]))
	elif dif<0:
		print(sum(ed[:abs(dif)-1]))
