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