n=int(input())
a=list(map(int, input().split()))
b=[]
c=[]
for i in range(n):
    if a[i]%2==0:
        b.append(a[i])
    else:
        c.append(a[i])
b=sorted(b)
c=sorted(c)
if len(b)==len(c):
    print(0)
elif ((len(b)-len(c))==1) or ((len(b)-len(c))==-1):
    print(0)
elif len(b)>len(c):
    k=(len(b)-len(c))
    print(sum(b[0:k-1]))
else:
    k=(len(c)-len(b))
    print(sum(c[0:k-1]))