n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
a1 = []
a2 = []
for el in arr:
	if el % 2 == 0:
		a2.append(el)
	else:
		a1.append(el)
if (len(a1) < len(a2)):
	ans = 0
	for i in range(len(a2) - len(a1) - 1):
		ans += a2[i]
else:
	ans = 0
	for i in range(len(a1) - len(a2) - 1):
		ans += a1[i]
print(ans)