n = int(input())
a = [int(i) for i in input().split()]
ch = []
nch = []
for i in a:
    if i % 2 == 0:
        ch.append(i)
    else:
        nch.append(i)
nch.sort()
nch.reverse()
ch.sort()
ch.reverse()

if len(ch) == len(nch):
    print(0)
elif abs(len(ch) - len(nch)) == 1:
    print(0)
elif abs(len(ch) - len(nch)) > 1:
    if len(ch) < len(nch):
        for i in range(len(ch)+1):
            nch.remove(nch[i])
        min = sum(nch)
    if len(nch) < len(ch):
        for i in range(len(nch)+1):
            ch.remove(ch[i])
        min = sum(ch)






