n = int(input())
a = [int(x) for x in input().split()]
b = sorted(list(filter(lambda x:x%2==1, a)))
c = sorted(list(filter(lambda x:x%2==0, a)))
b.reverse()
c.reverse()

lb = len(b)
lc = len(c)
if lb > lc + 1:
	print(sum(b[lc+1:]))
elif lc > lb + 1:
	print(sum(c[lb+1:]))
else:
	print(0)

