n=int(input())
l=[int(x) for x in input().split()]
l.sort(reverse = True)
ev=0
od=0
for i in range(n):
	if(l[i]&1==0):
		ev+=1
	else:
		od+=1
d=abs(ev-od)
if(d==0 or d==1):
	print(0)
else:
	if(ev<od):
		ge=ev
		go=ev+1
	else:
		go=od
		ge=od+1
	j=0
	while(ge>0 or go>0):
		if(l[j]&1==0):
			if(ge>0):
				ge-=1
				l[j]=0
		else:
			if(go>0):
				go-=1
				l[j]=0
		j+=1
	print(sum(l))

