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