n=int(input())
c=list(map(int,input().split()))
c=sorted(c)[::-1]
count_even,count_odd=0,0
for i in range(len(c)):
	if c[i]%2==0:
		count_even+=1
	else:
		count_odd+=1
		

if abs(count_even-count_odd)<=1:
	print(0)
else:
	r=abs(count_even-count_odd)-1
	c=sorted(c)
	tot=0
	for i in range(r):
		tot+=c[i]
	print(tot)
	
