n=int(input())
ch=input()
L=ch.split(' ')
odd=[]
even=[]
for i in L:
    if int(i)%2==0 :
        even.append(int(i))
    else:
        odd.append(int(i))

even.sort()
odd.sort()
d=len(even)-len(odd)

if d>=1:
    print(sum(even[:abs(d)-1]))
elif  d <=-1:
    print(sum(odd[:abs(d)-1]))
elif d==0:
    print('0')