x=int(input())
a=list(map(int,input().split()))
even=[]
odd=[]
new=[]
s=0
suc=True
c=0
for i in a:
	if i%2==0:
		even.append(i)
	else:
		odd.append(i)
if len(even)>len(odd):
	c=0
else:
	c=1
even.sort()
odd.sort()
while suc==True:
	if c==0:
		even.remove(even[-1])
		c=1
	else:
		odd.remove(odd[-1])
		c=0
	if len(even)==0 and c==0:
		suc=False
	if len(odd)==0 and c==1:
		suc=False
new=even+odd
for i in new:
	s=s+i
print(s)
