n=int(input())
l=list(map(int,input().split()))
l1=[]
l2=[]
for i in range(len(l)):
    if(l[i]%2==0):
        l1.append(l[i])
    else:
        l2.append(l[i])
l1.sort()
l2.sort()
if(abs(len(l1)-len(l2))==0 or abs(len(l1)-len(l2))==1):
    print("0")
else:
    sum1=0
    if(len(l1)>len(l2)):
        for j in range(len(l1)-len(l2)-1):
            sum1=sum1+l1[j]
    else:
        for j in range(len(l2)-len(l1)-1):
            sum1=sum1+l2[j]
    print(sum1)
            