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