n = input()
a = list(map(int,raw_input().split()))
a.sort()
p=[]
np=[]
for i in range(len(a)):
	if a[i]%2 == 0:
		p.append(a[i])
	else:
		np.append(a[i])
del a
b=len(p)
c=len(np)
ans = 0
if b>c:
	for i in range(b-c-1):
		ans+=p[i]
else:
	for i in range(c-b-1):
		ans+=np[i]
print ans
