input()
n=list(map(int, input().split()))
o=[]
e=[]
for i in n:
    if(i%2==0): e.append(i)
    else: o.append(i)
o.sort(reverse=True)
e.sort(reverse=True)
if(len(e)>len(o)):
    print(sum(e[len(o)+1:]))
else:
    print(sum(o[len(e)+1:]))