n = int(input())

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

a.sort()

chectcn = 0
for i in a:
    if i%2==0:
        chectcn+=1
nechetcnt = n-chectcn

if chectcn>nechetcnt:
    m = 0
else:
    m = 1

cnt_to_sum = abs(chectcn-nechetcnt)-1
if cnt_to_sum<0:
    cnt_to_sum = 0

summ = 0
if cnt_to_sum:
    for i in a:
        if i%2==m:
            summ+=i
            cnt_to_sum -= 1
            if cnt_to_sum == 0: break

        
        

print(summ)
