num=int(input())
arr=list(map(int,input().split()))
odd=[]
even=[]
for i in arr:
  if i%2==0:
    even.append(i)
  else:
    odd.append(i)
even.sort()
odd.sort()    
e=len(even)
o=len(odd)    
ans=0
if o<e:
  ans=sum(even[:e-o-1])
  print(ans)
else:
  ans=sum(odd[:o-e-1])
  print(ans)