a = input()
b = input()
hi = sorted([int(i) for i in b.split()])
hi = hi[::-1]
de = []
even = []
odd = []
result = []
counter = 0
for i in hi:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

if len(even) == len(odd) or abs(len(even) - len(odd)) == 1:
    print(0)
else:
    if len(even) > len(odd):
        counter = sum(odd) + sum(even[0:len(odd)])
    else:
        counter = sum(even) + sum(odd[0:len(even)])
    print(sum(hi) - counter)


