n=int(input())
arr=list(map(int,input().split()))
even=[]
odd=[]
for i in range(n):
	if arr[i]&1:
		odd.append(arr[i])
	else:
		even.append(arr[i])
odd.sort()
even.sort()
#odd start
# print(even,odd)
times=min(len(odd),len(even))+1
# print(times)
smo=0
for i in range(len(odd)-times):
	smo+=odd[i]
sme=0
for i in range(len(even)-times):
	# print("bh")
	sme+=even[i]
print(max(sme,smo))