n, a = int(input()), list(map(int, input().split()))
odd, even = sorted(filter(lambda x: x % 2, a)), sorted(filter(lambda x: x % 2 == 0, a))

if len(odd) == len(even):
    print(0)
elif len(odd) > len(even):
    print(sum(odd[:len(odd) - len(even) - 1]))
else:
    print(sum(even[:len(even) - len(odd) - 1]))
