n = int(input())
A = [int(i) for i in input().split()]

odds = [A[i] for i in range(n) if A[i]&1]
evens = [A[i] for i in range(n) if A[i]&1==0]
odds.sort()
evens.sort()
if len(odds) < len(evens):
    print(sum(evens[:max(0, len(evens)-len(odds)-1)]))
else:
    print(sum(odds[:max(0, len(odds)-len(evens)-1)]))
