n=(int)(input())
l=list(map(int , input().split()))
ao=[]
ae=[]
for i in range(len(l)):
    if (l[i]%2==0):
        ae.append(l[i])
    else:
        ao.append(l[i])
ae.sort()
ao.sort()
if(len(ae)==len(ao)):
    print('0')
else:
    if(len(ae)>len(ao)):
        sum=0
        for i in range(len(ae)-len(ao)-1):
            sum+=ae[i]
        print(sum)
    else:
        sum=0
        for i in range(len(ao)-len(ae)-1):
            sum+=ao[i]
        print(sum)