n=int(input())
a=list(map(int,input().strip().split()))
a.sort()
even=0
ev=[]
od=[]
odd=0
s=0
for i in a:
	if i%2==0:
		even=even+1
		ev.append(i)
	else:
		odd=odd+1
		od.append(i)
if(abs(even-odd)==1 
	or even-odd==0):
	print(0)
elif(even>odd):
	for i in range(0,even-odd-1):
		s=s+ev[i]
	print(s)
else:
	for i in range(0,odd-even-1):
		s=s+od[i]
	print(s)	





