n = int(input())
l = list([int(x) for x in input().split()])

o = []
so = 0
e = []
se = 0

for i in l:
    if(i % 2 == 0):
        se += 1
        e.append(i)
    else:
        so += 1
        o.append(i)

if(se == so or abs(se-so) == 1):
    print('0')
elif(len(o) > 0 and len(e) > 0):
    o.sort()
    e.sort()
    sum = 0
    if(se >= so):
        for i in range(0, se-(so+1)):
            sum += e[i]
    else:
        for i in range(0, so-(se+1)):
            sum += o[i]
    print(sum)
else:
    o.sort()
    e.sort()
    if(so > 0):
        print(sum(o) - o[so-1])
    else:
        print(sum(e)-e[se-1])
