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