n = int(input())
a = list(map(int,input().split()))
b = [i for i in a if i%2==0]
c = [i for i in a if i%2==1]
p,q = len(b),len(c)
b.sort()
c.sort()
if p>q:
    if p==q+1:
        print(0)
    else:
        print(sum(b[:p-(q+1)]))
elif p<q:
    if q==p+1:
        print(0)
    else:
        print(sum(c[:q-(p+1)]))
else:
    print(0)