n = int(input())
a = [int(i) for i in input().split()]
chet = sorted([i for i in a if i % 2 == 0])
nechet = sorted([i for i in a if i % 2 == 1])
razn = abs(len(chet) - len(nechet))
if len(chet) > len(nechet):
    mx = chet
else:
    mx = nechet

if razn > 1:
    print(sum([mx[i] for i in range(razn - 1)]))
else:
    print(0)
