n=int(raw_input())
l=map(int, raw_input().split())
l=sorted(l)

ev, od= 0, 0
for i in range(n):
    if l[i]%2==0:
        ev+=1
    else:
        od+=1

if abs(ev-od)<=1:
    print(0)
    exit(0)

if ev>od+1:
    count, i, res=0, 0,0
    while count < ev-(od+1):
        if l[i]%2==0:
            count+=1
            res+=l[i]
        i+=1
    print(res)

else:
    count, i, res=0, 0,0
    while count < od-(ev+1):
        if l[i]%2==1:
            count+=1
            res+=l[i]
        i+=1
    print(res)