a=int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
B = []
C = []
b = 0
c = 0
for i in range(a):
    if A[i] % 2 == 0:
        B.append(A[i])
        b+=1
    else:
        C.append(A[i])
        c+=1
if b > c+1:
    B = B[c+1:b]
    print(sum(B))
elif c > b+1:
    C = C[b+1:c]
    print(sum(C))
else:
    print(0)