# created by : M1TKU
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
a.reverse()
o = 0
e = 0
ans = 0
b = []
c = []
for i in range(len(a)):
	if a[i]%2 == 1:
		b.append(a[i])
		o += 1
	else:
		e += 1
		c.append(a[i])
if o > e:
	i = o - (e+1)
	ans = sum(b[o-i:])
	ans += sum(c[e:])
elif e > o:
	i = e - (o+1)
	ans = sum(b[o:])
	ans += sum(c[e-i:])
else:
	ans = sum(b[o:])
	ans += sum(c[e:])

print(ans)