
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt()
  var x = sc.next()
  def pop(num:Int): Int ={
    var nua = num
    var counts = 0
    while (nua != 0 & nua.toBinaryString.count(_ =='1') != 0){
      nua = nua % nua.toBinaryString.count(_ =='1')
      counts += 1
    }
    return counts
  }
  var tmp = x
  for (i <- 0 until n){
    tmp = x
    if(tmp(i)=='0'){tmp=tmp.updated(i,'1')}else{ tmp=tmp.updated(i,'0')}
    println(pop(java.lang.Integer.parseInt(tmp,2)))
  }
}
