t = int(input())
l = list(map(int, input().split()))
pair = [x for x in l if(x%2==0)]
unpair = [x for x in l if(x%2==1)]
pair.sort()
unpair.sort()
pair.reverse()
unpair.reverse()
n = len(pair)
m = len(unpair)
if n == m or abs(n - m) == 1:
	print(0)
else:
	if n > m:
		print(sum(pair[m+1:]))
	else:
		print(sum(unpair[n+1:]))