n=int(input())
odd=odd_sum=even=even_sum=0
even_list=[]
odd_list=[]
x=list(map(int,input().split()))
for i in range(n):
    if x[i]%2==0:
        even+=1
        even_list.append(x[i])
        even_sum+=x[i]
    else:
        odd+=1
        odd_list.append(x[i])
        odd_sum+=x[i]
even_list.sort()
odd_list.sort()
if(odd>even):
    print(sum(odd_list[0:odd-even-1]))
elif (even>odd):
    print(sum(even_list[0:even-odd-1]))
else:
    print(0)
    
    
    
