n = gets.chomp.to_i
x = gets.chomp

(0...n).each do |i|
  nowx = x.dup
  nowx[i] = nowx[i] == '1' ? '0' : '1'
  now = nowx.to_i(2)

  ans = 0
  while now > 0
    now %= nowx.count('1')
    nowx = now.to_s(2)
    ans += 1
  end
  puts ans
end