n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
    if a[i]%2==0:
        e.append(a[i])
    else:
        o.append(a[i])
if len(o)==len(e):
    print(0)
    exit()
o.sort()
e.sort()
m=min(len(o),len(e))
if len(o)==m:
    ans=0
    for i in range(len(e)-(m+1)):
        ans+=e[i]
    print(ans)
    exit()
ans=0
for i in range(len(o)-(m+1)):
    ans+=o[i]
print(ans)

    