n=int(input())
l=list(map(int,input().split()))
o,e=[],[]
for i in range(n):
    if l[i]%2==0:
        e.append(l[i])
    else:
        o.append(l[i])
a=len(e)
b=len(o)
if(a==b or a+1==b or b==a+1):
    print('0')
else:
    m=min(a,b)
    if(a>m):
        print(sum(e[m+1:]))
    else:
        print(sum(o[m+1:]))
    