n=int(input())
ar=[int(x) for x in input().split()]
e=[]
o=[]
for k in ar:
    if k%2==0:
        e.append(k)
    else:
        o.append(k)
e.sort()
o.sort()
ee=len(e)
oo=len(o)
if (ee==oo) or ee-oo==-1 or ee-oo==1:
    print(0)
else:
    if ee>oo:
        print(sum(e[oo+1:]))
    else:
        print(sum(o[ee+1:]))
        
