n=int(input())
l=list(map(int, input().split()))
e,o=[],[]
l.sort()
l=l[::-1]
for i in l:
    if(i&1):
        o.append(i)
    else:    
        e.append(i)
#print(e,o)        
if(len(e)==len(o)):
    print(0)
else:
    m=min(len(e),len(o))
    if(len(e)<len(o)):
        e=[]
        for i in range(m+1):
            o.pop(0)
        print(sum(o))    
    else:
        o=[]
        for i in range(m+1):
            e.pop(0)
        print(sum(e))        
            