n= int(input())
a= list(map(int, input().split()))
e=0
o=0
el= []
ol= []


for i in range(n):
    if a[i]%2== 0:
        e+=1
        el.append(a[i])
    else:
        o+=1
        ol.append(a[i])
        
if e>o:
    print(sum(el[o:]))
    
else:
    print(sum(ol[e:]))