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:
    a = abs(o-e)-1
    sum = 0
    for i in range(a):
        sum+=A[i]
    print(sum)
