#1 5 7 8 2 3
z=[]
x=int(input())
s=[int(n) for n in input().split()]
s.sort()
s=s[::-1]
z+=[n%2 for n in s]
evv=z.count(0)
odd=z.count(1)
e=[n for n in s if n%2==0]
o=[n for n in s if n%2==1]
if evv>odd:
	print(sum(e[odd+1:]))
elif odd>evv:
	print(sum(o[evv+1:]))
else:
	print(0)		
	
	