n = int(input())
a = [int(i) for i in input().split()]
evens = [i for i in a if i % 2 == 0]
odds = [i for i in a if i % 2 == 1]
evens.sort()
evens = evens[::-1]
odds.sort()
odds = odds[::-1]
evenCount = len(evens)
oddCount = len(odds)
if evenCount == oddCount or abs(evenCount - oddCount) == 1:
    print(0)
else:
    if evenCount > oddCount:
        print(sum(evens[oddCount + 1 :]))
    else:
        print(sum(odds[evenCount + 1:]))
        