a=int(input())
z=list(map(int,input().split()))
even=[]
odd=[]
for i in range(len(z)):
    if(z[i]%2==0):
        even.append(z[i])
    else:
        odd.append(z[i])
even=sorted(even)
even=even[::-1]

odd=sorted(odd)
odd=odd[::-1]
if(abs(len(odd)-len(even))==1 or len(odd)==len(even)):
    print(0)
else:
    if(len(odd)>len(even)):
        t=sum(odd[0:len(even)+1:])+sum(even)
    else:
        t=sum(even[0:len(odd)+1:])+sum(odd)
    print(t)    
    
    
