n = int(input())
a = list(map(int, input().split()))

odd = 0
even = 0

odds = []
evens = []

for x in a:
    if x % 2:
        even+=1
        evens.append(x)
    else:
        odd+=1
        odds.append(x)

if odd - 1 > even:
    odds.sort()
    print(sum(odds[:odd-even-1]))
    exit()


if even - 1 > odd:
    evens.sort()
    print(sum(evens[:even-odd-1]))
    exit()

print(0)

