n=int(input())
arr=[int(i) for i in input().split()]
arr.sort()
e,o=0,0
l=[]
m=[]
for i in arr:
    if i%2==0:
        e+=1
        l.append(i)
    else:
        o+=1
        m.append(i)
if abs(e-o)<2:print(0)
elif e>o:
    x=(e-o-1)
    print(sum(l[:x]))
elif o>e:
    x = (o - e - 1)
    print(sum(m[:x]))