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

li = []
for i in 0..n do
  cnt = 0
  p = Math.log(n,2).floor
  while p != -1
    if i>=2**p
      cnt += 1
      i -= p
    end
    p -= 1
  end
  li.push(cnt)
end

for i in 2..n do
  li[i] = li[i%li[i]]+1
end

###########################################
num = 0
for i in 0...a.size do
  num += a[i]
end

waru = [num-1,num+1]
amari = []
for i in waru do
  temp = []
  for j in 0...i do
    temp.push(2**j%i)
  end
  amari.push(temp)
end

sum = [0,0]
for i in 0...waru.size do
  for j in 0...a.size do
    sum[i] += a[a.size-1-j] * amari[i][j%waru[i]]
  end
end
sum[0] %= waru[0]
sum[1] %= waru[1]
##############################
ans = []
for i in 0...n do
  if a[a.size-1-i]==0
    ans.push((sum[1]+amari[1][i%waru[1]])%waru[1])
  else
    ans.push((sum[0]-amari[0][i%waru[0]])%waru[0])
  end
end

ans = ans.reverse
for i in 0...ans.size
  puts li[ans[i]]+1
end