n = int(input())
A = list(map(int, input().split()))
A1 = sorted(a for a in A if a%2)
A2 = sorted(a for a in A if a%2==0)
mlen = min(len(A1), len(A2))
A1, A2 = A1[:len(A1)-mlen], A2[:len(A2)-mlen]
print(sum((A1+A2)[:-1]))