n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
c1,c2=0,0
l1,l2=[],[]
for i in range(n):
	if b[i]%2!=0:
		l1.append(b[i])
		c1+=1
	else:
		l2.append(b[i])
		c2+=1
if c1==c2:
	print(0)
elif c1>c2:
	t = 0
	for i in range(0,c1-c2-1):
		t+= l1[i]
	print(t)
else:
	k=0
	for i in range(0,c2-c1-1):
		k+=l2[i]
	print(k)
