n=int(input())
x,count,even,z = sorted(list(map(int, input().split(" ")))),0,0,1
for i in x:
    if i%2==0: even+=1
odd=n-even
if abs(even-odd)==1 or odd==even:
    print(0)
    exit()
else:
    if even>odd:z=0
    i,sum=0,0
    while count<n-(min(even,odd)*2+1):
        if x[i]%2==z:
            sum+=x[i]
            count+=1
        i+=1
    print(sum)