N=int(input())
odd=[];even=[]
for i in map(int,input().split()):
    odd.append(i) if i%2 else even.append(i)

if len(odd)==len(even):
    print(0)
    exit()

if len(odd)>len(even):
    odd,even=even,odd
# even longer
even.sort(reverse=1)
print(sum(even[len(odd)+1:]))