def parity_brute_force(x):
    bit = 0
    num_bits = 0
    while x:
        bitmask = 1 << bit
        bit += 1
        if x & bitmask:
            num_bits += 1
        x &= ~bitmask

    return num_bits % 2

n=int(input())
s=list(map(int,input().split()))
s.sort()
o=[]
e=[]
par=[]
for i in s:
    if(i%2):
        o.append(i)
    else:
        e.append(i)
x=len(o)
y=len(e)
if(x>y+1):
    print(sum(o[:x-y-1]))
elif(y>x+1):
    print(sum(e[:y-x-1]))
else:
    print(0)