input()
odd = []
even = []
s = list(map(int, input().split()))
for i in s:
	odd.append(i) if i%2 == 0 else even.append(i)
if len(odd) == len(even) or abs(len(odd)-len(even)) == 1:
	print(0)
	exit()

if len(odd) == 0:
	print(sum(sorted(even[:len(even)-1])))
	exit()
if len(even) == 0:
	print(sum(sorted(odd[:len(odd)-1])))
	exit()

if len(odd) > len(even):
	print(sum(sorted(odd[:len(odd)-len(even)])))
else:
	print(sum(sorted(even[:len(even)-len(odd)])))