N = int(input())
A = list(map(int, input().split()))

odds = [i for i in A if i % 2 == 1]
evens = [i for i in A if i % 2 == 0]

nodds = len(odds)
nevens = len(evens)

if nodds == nevens or abs(nodds - nevens) == 1:
	res = 0
else:
	if nodds < nevens:
		diff = nevens - nodds - 1
		sevens = sorted(evens, reverse=True)
		res = sum(sevens[-diff:])

	elif nevens < nodds:
		diff = nodds - nevens - 1
		sodds = sorted(odds, reverse=True)
		res = res = sum(sodds[-diff:])

print(res)