n = input()

l = list(map(int, raw_input().split()))

odd = []

even = []

for _ in l:
    
    if _ % 2 != 0:

        odd.append(_)
        
    else:
        
        even.append(_)

k = len(odd)-len(even)

if (k == 0 or abs(k) == 1):
    
    print 0
    
else:

    odd.sort()

    even.sort()

    if k < 0:

        print sum(even[:abs(k)-1])

    else:

        print sum(odd[:k-1])