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