n=int(input())
l=sorted(list(map(int,input().split())))
a=[]
b=[]
w=0
c=0
r=0
for i in range(n-1,-1,-1):
    if(l[i]%2==0):
        a.append(l[i])
    else:
        b.append(l[i])
c=min(len(a),len(b))
if(len(a)!=0 and len(b)==0):
    print(sum(l)-a[0])
elif(len(b)!=0 and len(a)==0):
    print(sum(l)-b[0])
elif(abs(len(a)-len(b))<=1):
    print(0)
else:
    if(c==len(a)):
        r=sum(a[0:c])+sum(b[0:c+1])
    else:
        r=sum(a[0:c+1])+sum(b[0:c])
    print(sum(l)-r)