a=int(input())
b=list(map(int,input().split()))
c=[]
d=[]
for i in range(a):
    if b[i]%2==0:
        c.append(b[i])
    else:
        d.append(b[i])
m=len(c)
n=len(d)
if m==n or abs(m-n)==1:
    print(0)
else:
    c.sort()
    d.sort()
    p=min(m,n)
    if p==n:
        t=m-p-1
        print(sum(c[0:t]))
    else:
        t=n-p-1
        print(sum(d[0:t]))