a = int(input())
arr = list(map(int,input().split()))
odd = []
even = []
for i in arr:
	if i%2==0:
		even.append(i)
	else:
		odd.append(i)
odd.sort()
even.sort()
ans = []
if len(odd)>len(even):
	ans = odd[:len(odd)-len(even)]
else:
	ans = even[:len(even)-len(odd)]

if(len(ans)>0):
		ans.pop()
print(sum(ans))
