def run(n,a):
    even=sorted([i for i in a if i%2==0], reverse=True)
    odd=sorted([i for i in a if i%2!=0], reverse=True)
    # print(even)
    # print(odd)
    l1=len(even)
    l2=len(odd)
    if l1<l2:
        print(sum(odd[l1+1::]))
    elif l2<l1:
        print(sum(even[l2+1::]))
    else:
        print(0)

    
n=int(input())
a=list(map(int, input().split()))
run(n,a)
        
