n = input()
a = []
b = []
for i in map(int,raw_input().split()):
    if i%2==0:
        a.append(i)
    else:
        b.append(i)
a = sorted(a)
b = sorted(b)
na = len(a)
nb = n - na
if na>nb:
    print sum(a[:na-nb-1])
elif nb>na:
    print sum(b[:nb-na-1])
else:
    print 0