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