n = map(int, input().split())

arr = list(map(int, input().split()))

x1 = [a for a in arr if a % 2 == 0]
x2 = [a for a in arr if a % 2 != 0]

x1.sort()
x1 = x1[::-1]

x2.sort()
x2 = x2[::-1]

len_ = min(len(x1), len(x2))

x1 = x1[len_:]
x2 = x2[len_:]

if len(x1) == 0 and len(x2) == 0:
    print(0)

elif len(x1) == 0:
    print(sum(x2[1:]))
elif len(x2) == 0:
    print(sum(x1[1:]))

else:
    print(min(sum(x1 + x2[1:]), sum(x1[1:] + x2)))
