n = int(input(""))
a=input("").split()
odd=[]
even=[]
for i in range(n):
    a[i]=int(a[i])
    (odd if a[i]%2==1 else even).append(a[i])
if(-1<=len(odd)-len(even)<=1):
    print(0)
else:
    n=len(odd)-len(even)
    if n<0:
        n=-n
    n-=1 # number to call
    w=odd
    if(len(odd)<len(even)):
        w=even
    w.sort()
    #print(w)
    total=sum(w[:n])
    print(total)

        