n = int(input())
l=[int(e.strip()) for e in input().strip().split()]
l.sort()
od=[]
ev=[]
for e in l:
    if e%2==0:
        ev.append(e)
    else:
        od.append(e)
if -2<len(ev)-len(od)<-1:
    print(0)
elif len(ev)<len(od):
    sum=0
    for i in range(len(od)-len(ev)-1):
        sum += od[i]
    print(sum)
else:
    sum = 0
    for i in range(len(ev) - len(od) - 1):
        sum += ev[i]
    print(sum)


