n = int(input())
a = list(map(int, input().split()))
e = []
o = []
for i in a:
    if i % 2 == 0:
        e.append(i)
    else:
        o.append(i)

if len(e) < len(o):
    o.sort()
    print(sum(o[0:(len(o)-len(e)-1)]))
elif len(o) < len(e):
    e.sort()
    print(sum(e[0:(len(e)-len(o)-1)]))
else:
    print(0)
