# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("output4.out",'w')
		
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x,y=0,0
for i in a:
		if i%2==0:
			y+=1
		else:
			x+=1
p=abs(x-y)			
if p<=1:
	print(0)
else:
	s=0
	while p>=2:
		s+=a.pop()
		p-=1
		
	print(s)	
