n=int(input())
e=[]
o=[]
arr=input().split()
for ele in arr:
    k=int(ele)
    if(k%2==0):
        e.append(k)
    else:
        o.append(k)
e.sort()
o.sort()
if(len(e)-len(o)<=1 and len(e)-len(o)>=-1):
    print(0)
else:
    if(len(e)>len(o)):
        k=len(e)-len(o)-1
        t=0
        for i in range(0,k):
            t=t+e[i]
        print(t)
    else:
        k=len(o)-len(e)-1
        t=0
        for i in range(0,k):
            t=t+o[i]
        print(t)
        
        
            
