n = int(input())
a = sorted(list(map(int,input().split())))
z,x,s,m =0,0,0,0
for i in a:
	if i%2==0:z+=1
	else:x+=1
if z-x-1>0:
	for i in a:
		if i%2==0:s+=i;m+=1
		if m == z-x-1 :print(s);break
elif x-z-1>0:
	for i in a:
		if i%2!=0:s+=i;m+=1
		if m == x-z-1 :print(s);break
else:print(0)