n=gets.to_i
$f=Hash.new(0)
s=gets.chomp
x=s.to_i(2)
d=s.count("1")
c=0
y=0
k=2**(n-1)
def ff(y,d,s)
  if $f[y]==0&&d>0
    r=y%d
    s << [y,r]
    ff(r,r.to_s(2).count("1"),s)
  else
    return s
  end
end
n.times do |i|
  if s[i]=="0"
    y=x+k
    c=d+1
  else
    y=x-k
    c=d-1
  end
  if $f[y]==0
    ff(y,c,[]).reverse_each do |sy,sr|
#      p [sy,sr]
      $f[sy]=$f[sr]+1
    end
  end
#  p [y,$f[y]]
  puts $f[y]
  k/=2
end
#p $f
