n=int(input())
l=list(map(int,input().split()))
l1=[]
l2=[]
for i in l:
    if i%2:
        l1.append(i)
    else:
        l2.append(i)
if abs(len(l1)-len(l2))<=1:
    print(0)
else:
    a=len(l1)
    b=len(l2)
    l1.sort()
    l2.sort()
    if a>b:
        print(sum(l1[:a-b-1]))
    else:
        print(sum(l2[:b-a-1]))

