input()
temp = [int(x) for x in input().split()]
even = list()
odd = list()
for i in temp:
    if i % 2:
        odd.append(i)
    else:
        even.append(i)
if len(odd) + 1 == len(even) or len(odd) == len(even) or len(odd) - 1 == len(even):
    print(0)
elif len(odd) + 1 < len(even):
    even.sort()
    print(sum(even[0:(len(even)-len(odd)-1)]))
elif len(even) + 1 < len(odd):
    odd.sort()
    print(sum(odd[0:(len(odd)-len(even)-1)]))
