//import Foundation

struct Nums: Equatable, Hashable {
    var a, b, c: Int
    init(_ a: Int, _ b: Int, _ c: Int) {
        (self.a, self.b, self.c) = (a, b, c)
    }
    static func ==(l: Nums, r: Nums) -> Bool {
        [l.a, l.b, l.c].sorted() == [r.a, r.b, r.c].sorted()
    }
    var pattern: Int {
        if a == b, b == c {
            return 1
        } else if a == b || b == c || a == c {
            return 3
        } else {
            return 6
        }
    }
}

func popcount(_ n: Int) -> Int {
    String(n, radix: 2).filter { $0 == "1" }.count
}

func f(n: Int) -> Int {
    var n = n, res = 0
    while n != 0 {
        n %= popcount(n)
        res += 1
    }
    return res
}

let n = readInt()
let x = Int.init(readLine()!, radix: 2)!
for i in 1...n {
    let xi = x ^ (1 << (n-i))
//    print(xi)
    print(f(n: xi))
}


// MARK: -----------------------------------------------------------------------


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

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}
