n=int(input())
l=list(map(int,input().split()))
l.sort()
e=[]
o=[]
for i in range(n):
    if l[i]%2==0:
        e.append(l[i])
    else:
        o.append(l[i])
out=0
c=0
if len(e)>len(o):
    s=len(o)
    c+=sum(o)
    c+=sum(e[:s+1])
    print(sum(l)-c)
elif len(o)>len(e):
    s=len(e)
    c+=sum(e)
    c+=sum(o[:s+1])
    print(sum(l)-c)
else:
    print(0)