

n = int(input())


s = list(map(int , str(input()).split()))
s = sorted(s)
s = s[::-1]
sp = [x for x in s if x%2==0]
si = [x for x in s if x%2==1]


if abs(len(sp)-len(si)) < 2:
	print(0)
else:
	if len(sp) > len(si):
		print(sum(sp[len(si)+1:]))
	if len(si) > len(sp):
		print(sum(si[len(sp)+1:]))
