'''input
2
1000000 1000000

'''

N = int(input())

sk = [int(x) for x in input().split()]

lyg = []
nel = []

for i in sk:
	if i & 1:
		nel.append(i)
	else:
		lyg.append(i)


did = min(len(nel), len(lyg))

if len(nel) > did:
	nel.sort()
	print(sum(nel[:len(nel)-did-1]))
elif len(lyg) > did:
	lyg.sort()
	print(sum(lyg[:len(lyg)-did-1]))
else:
	print(0)