local mfl, mce = math.floor, math.ceil
local n = io.read("*n", "*l")
local t = {}
local s = io.read()
local cnt1 = 0
for i = 1, n do
  t[i] = s:byte(i) == 49
  if t[i] then cnt1 = cnt1 + 1 end
end

local function firstdevide(p, dv)
  local currem = 0
  for i = 1, n do
    currem = currem * 2
    if i == p then
      if not t[i] then
        currem = currem + 1
      end
    else
      if t[i] then
        currem = currem + 1
      end
    end
    currem = currem % dv
  end
  return currem
end

local function getpopcnt(x)
  local c = 0
  while 0 < x do
    if x % 2 == 1 then c = c + 1 end
    x = mfl(x / 2)
  end
  return c
end

for iq = 1, n do
  local dv = t[iq] and cnt1 - 1 or cnt1 + 1
  local rem = firstdevide(iq, dv)
  local cnt = 1
  while 0 < rem do
    dv = getpopcnt(rem)
    rem = rem % dv
    cnt = cnt + 1
  end
  print(cnt)
end
