n = int(input())
a = list(map(int,input().split()))
o =[]
e =[]
for i in a:
    if i%2==0:
        o.append(i)
    else:
        e.append(i)
o = sorted(o,reverse=True)
e = sorted(e,reverse=True)
if len(o)==len(e):
    print(0)
elif len(o) > len(e):
    o = o[len(e)+1:]
    print(sum(o))
else:
    e = e[len(o)+1:]
    print(sum(e))