input()
a = [*map(int, input().split())]
even = sorted(list(filter(lambda x: x % 2 == 0, a)), reverse = True)
odd = sorted(list(filter(lambda x: x % 2 != 0, a)), reverse = True)
if abs(len(even) - len(odd)) < 2:
    s = 0
else:
    k = min(len(even), len(odd))
    if len(even) == k:
        s = sum(odd[k+1:])
    else:
        s = sum(even[k+1:])
print(s)