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