n = int(input())
mas = list(map(int, input().split()))
ch = []
nch = []
for i in mas:
    if i % 2 == 1:
        nch.append(i)
    else:
        ch.append(i)
ch.sort(reverse=True)
nch.sort(reverse=True)
for i in range(min(len(ch), len(nch))):
    ch.pop(0)
    nch.pop(0)
if (len(ch) <= 1) & (len(nch) <= 1):
    print(0)
else:
    if len(ch) > 1:
        print(sum(ch[1::]))
    else:
        print(sum(nch[1::]))
