import scala.io.StdIn._

object Main extends App {


  val n = readInt()
  val x = readLine()

  def solve() = {
    (0 until n).map { i =>
      val reverseBit = if(x(i).toString == "1") "0" else "1"
      val replacedX = x.take(i) + reverseBit + x.drop(i+1)
      val num = parseLong(replacedX)
      f(num, 1)
    }.mkString("\n")
  }

  def f(x: Long, cnt: Int): Int = {
    val r = x % x.toBinaryString.count(_.toString == "1")
    if(r == 0) cnt
    else f(r, cnt+1)
  }

  import java.math.BigInteger

  def parseLong(s: String) = {
    new BigInteger(s, 2).longValue()
  }

  println(solve())

}

