n = int(input())
a = [int(x) for x in input().split()]

odd = sorted(filter(lambda x: (x % 2 == 1), a))
even = sorted(filter(lambda x: (x % 2 == 0), a))

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