object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val X = BigInt(in.next, 2)
  val Zero = BigInt(0)
  
  def f(n: BigInt, cnt: Int): Int = {
    if (n == Zero) cnt
    else f(n.mod(n.bitCount), cnt + 1)
  }

  val bits = X.bitCount

  println(((N - 1 to 0 by -1).map {i =>
    (bits + (if (X.testBit(i)) -1 else 1)) match {
      case 0 => 0
      case newBits => f(X.flipBit(i).mod(newBits), 1)
    }
  }).mkString("\n"))
}