n = int(input())
a = [int(i) for i in input().split()]
odd = [i for i in a if i % 2 == 0]
even = [i for i in a if i % 2 != 0]
odd.sort()
even.sort()
if len(even) == len(odd) + 1 or len(even) + 1 == len(odd) or len(even) == len(odd):
    print('0')
else:
    nums = abs(len(even) - len(odd)) - 1
    summ = 0
    if len(odd) > len(even):
        summ = sum(odd[:nums:])
    else:
        summ = sum(even[:nums:])
    print(summ)