n = int(input())
A = list(map(int,input().split()))
A.sort()
o=0;e=0
for i in range(n):
    if(A[i]%2):
        o+=1
    else:
        e+=1
if(abs(o-e)<2):
    print(0)
else:
    if(o>e):
        a = o-e-1;sum = 0
        for i in range(n):
            if(A[i]%2):
                sum+=A[i]
            a-=1
            if(a==0):
                break
    else:
        a = e-o-1;sum = 0
        for i in range(n):
            if(A[i]%2==0):
                sum+=A[i]
            a-=1
            if(a==0):
                break
        print(sum)
