n = int(input())
nums = [int(s) for s in input().split(' ')]
odd = [num for num in nums if num&1 == 1]
even = [num for num in nums if num&1 == 0]
ol = len(odd)
oe = len(even)
if ol < oe - 1:
    diff = oe - ol - 1
    even.sort()
    print(sum(even[:diff]))
elif oe < ol - 1:
    diff = ol - oe - 1
    odd.sort()
    print(sum(odd[:diff]))
else:
    print(0)