n=int(input())
o=[]
e=[]
l=[int(i) for i in input().split()]
for i in l:
    if i%2==1:e.append(i)
    else:o.append(i)
x=len(e)
y=len(o)
if x==y:print(0)
elif x==0:
    print(sum(o[:y-1]))
elif y==0:
    print(sum(e[:x-1]))
elif x>y:
    print(sum(e[:x-y-1]))
elif x<y:
    print(sum(o[:y-x-1]))
