def nonDeleted(L):
	e = []
	o = []

	for i in L:
		if(i & 1):
			o.append(i)
		else:
			e.append(i)

	Le = len(e)
	Lo = len(o)
	d = abs(Le - Lo) - 1

	if (Le == Lo or d == 0):
		return 0

	if(Le > Lo):
		Le = sorted(e)
		return sum(Le[0:d])
	Lo = sorted(o)
	return sum(Lo[0:d])



if __name__ == '__main__':
	n = int(input())
	L = list(map(int, input().rstrip().split()))
	print(nonDeleted(L))