n=int(input())
a=[int(x) for x in input().split()]
a.sort()
odd=[]
even=[]
for x in a:
	odd.append(x) if x%2!=0 else even.append(x)
if len(odd)>len(even):
	ans=sum(odd[:-len(even)-1])
elif len(even)>len(odd):
	ans=sum(even[:-len(odd)-1])
else:
	ans=0
print (ans)