def fn(x):
    if str(x)[-1] in '02468':
        return 1
    return 0
n=int(input())
l=[*map(int,input().split())]
l.sort()
p=0
f=[]
g=[]
for j in l:
    t=fn(j)
    p+=t
    if t==1:
        f.append(j)
    else:
        g.append(j)
m=n-p
if (p-m)==0 or abs(p-m)==1:
    print(0)
else:
    if p>m:
        print(sum(f[:-m-1]))
    else:
        print(sum(g[:-p-1]))
