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

E = []
O = []

for a in A:
    if a%2 == 0:
        E.append(a)
    else:
        O.append(a)

if len(E) >= len(O):
    if len(E)-len(O) <= 1:
        print(0)
    else:
        E.sort()
        print(sum(E[0:len(E)-len(O)-1]))
else:
    if len(O)-len(E) <= 1:
        print(0)
    else:
        O.sort()
        print(sum(O[0:len(O)-len(E)-1]))
