x=int(input())
p=list(sorted(map(int,input().split())))
sm,od,ev,lo,le=sum(p),[],[],0,0
for i in p:
    if i%2==0:
        ev.append(i)
        le+=1
    else:
        od.append(i)
        lo+=1
if lo==le:print(0)
elif lo>le:
    if le+1==lo:print(0)
    else :print(sum(od[:lo-(le+1)]))
elif le>lo:
    if lo+1==le:print(0)
    else :print(sum(ev[:le-(lo+1)]))
