t=int(input())
kp=list(map(int,input().split()))
even=[]
odd=[]
for ab in range(t):
    if (kp[ab]%2==0):
        even.append(kp[ab])
    else:
        odd.append(kp[ab])
even=sorted(even)
odd=sorted(odd)
if (abs(len(odd)-len(even))<=1):
    print(0)
else:
    if (len(odd)>len(even)):
        q=len(odd)-len(even)-1
        print(sum(odd[:q]))
    else:
        q=len(even)-len(odd)-1
        print(sum(even[:q]))
        
        
    
