n=int(input())
arr=map(int,input().split())
arr=sorted(arr)
even=0
for  i in arr:
    if(i%2==0):
        even=even+1
odd=n-even
finalSum=0
if(odd>even):
    i=0
    j=0
    while(i<odd-even-1):
        if(arr[j]%2!=0):
            finalSum+=arr[j]
            i+=1
        j+=1
else:
    i=0
    j=0
    while(i<even-odd-1):
        if(arr[j]%2==0):
            finalSum+=arr[j]
            i+=1
        j+=1
print(finalSum)
        
        
