N = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for x in a:
	if x % 2 == 0:
		even.append(x)
	else:
		odd.append(x)
even.sort()
odd.sort()
lenE = len(even)
lenO = len(odd)
if lenE == lenO or abs(lenE - lenO) == 1:
	print(0)
elif lenE > lenO:
	ind = lenE - lenO - 1
	ans = 0
	for i in range(0, ind):
		ans += even[i]
	print(ans)
else:
	ind = lenO - lenE - 1
	ans = 0
	for i in range(0, ind):
		ans += odd[i]
	print(ans)