n=gets.to_i
Y=gets.split('').map(&:to_i)

n.times do |i|

  x=[]
  x=Y.dup

 if x[i]==0
   x[i]=1 
 else
   x[i]=0 
 end
 a=x.join('').to_i(2)
  sum=0
 until a==0
    popcount=a.to_s(2).count('1')
    a=a%popcount
   sum+=1
 end
  p sum
end

