R=lambda: map(int,input().split())
n=[*R()][0]
l=[*R()]
odd,eve=sorted([i for i in l if i%2==1]),sorted([i for i in l if i%2==0])
if len(odd) == len(eve): print(0)
elif len(odd) > len(eve):
    print(sum(odd[:len(odd)-len(eve)-1]))
else: print(sum(eve[:len(eve)-len(odd)-1]))

