n=int(input())
l=list(map(int,input().split()))
odd=even=0
oddm=[]
evenm=[]
for i in range(n):
	if l[i]%2==0:
		even+=1
		evenm.append(l[i])
		
	else:
		odd+=1
		oddm.append(l[i])
		
oddm=sorted(oddm)
evenm=sorted(evenm)
# print(odd,even)
# print(oddm,evenm)
if even==odd+1 or even==odd-1:
	print(0)

else:
	if even>odd:
		print(sum(evenm[:even-odd-1]))
	elif odd>even:
		print(sum(oddm[:odd-even-1]))
	else:
		print(0)
