n=int(input())
a=list(map(int,input().split()))
a.sort()
m=len(a)
cnt=0
b=[]
c=[]
for i in range(0,m):
    if a[i]%2==0 :
        b.append(a[i])
    else:
        c.append(a[i])

cntb=len(b)
cntc=len(c)
ans=0
if abs(cntb - cntc) > 1:
    if(cntb > cntc):
        for i in range(0,cntb-cntc-1):
            ans +=  b[i]
    else:
        for i in range(0,cntc-cntb-1):
            ans +=  c[i]

print(ans)