n = int(input())
a = list(map(int, input().split()))
odd = [x for x in a if x%2 == 1]
eve = [x for x in a if x%2 == 0]
odd.sort()
eve.sort()
if abs(len(odd)-len(eve)) <= 1:
    print(0)
elif len(odd) < len(eve):
    x = len(eve) - len(odd) - 1
    print(sum(eve[:x]))
elif len(odd) > len(eve):
    x = len(odd) - len(eve) - 1
    print(sum(odd[:x]))