n=int(input())
l=[int(num) for num in input().split()]
e,o=[],[]
for i in range(n):
 if(l[i]%2==0):
  e.append(l[i])
 else:
  o.append(l[i])
l1,l2=len(e),len(o)
e.sort(reverse=True)
o.sort(reverse=True)

sum=0
if((l1-l2)==-1 or l1==l2 or (l1-l2==1)):
 pass
else:
 if(l1>l2):
  sum+=e[l2+1]
  for j in range(l2+2,l1):
   sum=sum+e[j]
 else:
  sum+=o[l1+1]
  for j in range(l1+2,l2):
   sum=sum+o[j]
print(sum)