import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func f(_ n: String, times: Int = 0) -> Int {
    var popcount = 0
    var point = 0

    n.reversed().enumerated().forEach {
        let number = Int(String($0.element))!
        popcount += number

        point += number * Int(pow(2.0, Double($0.offset)))
    }

    let result = point % popcount

    if result == 0 {
        return times + 1
    } else {
        return f(String(result, radix: 2), times: times + 1)
    }
}

func mainD() {

    let N = readInt()
    let X = readLine()!

    var results: [Int] = []

    for i in 0..<N {
        var Xi = Array(X)
        Xi[i] = Xi[i] == "1" ? "0" : "1"

        let result = f(String(Xi))
        results.append(result)
    }

    results.forEach { print($0) }
}

mainD()