n=int(input())
list=[int(i) for i in input().split()]
eve,odd=0,0
for i in range(n):
    if(list[i]%2):
        odd+=1
    else:
        eve+=1
if(abs(eve-odd)<=1):
    print('0')
    exit()
list.sort()
large=max(eve,odd)
cnt,i,j=0,0,0
if(large==eve):
    while(i<(eve-odd-1)):
        if(list[j]%2==0):
            cnt+=list[j]
            i+=1
        j+=1
else:
    while(i<(odd-eve-1)):
        if(list[j]%2):
            cnt+=list[j]
            i+=1
        j+=1
print(cnt)