n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ch = []
nch = []
for i in a:
    if i % 2 == 0:
        ch.append(i)
    else:
        nch.append(i)
if len(ch) == len(nch):
    print(0)
elif len(ch) > len(nch):
    print(sum(ch[len(nch) + 1:]))
else:
    print(sum(nch[len(ch) + 1:]))
