
n = int(input())

a = [ int(x) for x in input().split()]

odd = []
even = []

for x in a:
    if(x%2==0):
        even.append(x)
    else:
        odd.append(x)
        
leven = len(even)
lodd  = len(odd)

if(leven>lodd):
    even.sort()
    print(sum(even[:leven-lodd-1]))
    
elif(leven<lodd):
    odd.sort()
    print(sum(odd[:-leven+lodd-1]))
    
else:
    print(0)
    
    