#codeforces1144B_live
gi = lambda : list(map(int,input().strip().split()))
n, = gi()
l = gi()
ev = [e for e in l if e%2 == 0]
od = [e for e in l if e%2 == 1]
ev.sort(reverse=True)
od.sort(reverse=True)
if len(ev) > len(od):
	s = sum(ev[:len(od)+1])
	s += sum(od)
	ans = sum(l) - s
elif len(od) > len(ev):
	s = sum(od[:len(ev)+1])
	s += sum(ev)
	ans = sum(l) - s
else:
	ans = 0
print(ans)
