#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll n;
  string x;
  cin>>n>>x;
  
  ll bit=0,y;
  rep(i,n){
    if(x[i]=='1'){
      bit++;
      y=i;
    }
  }
  
  if(bit==0){
    rep(i,n) cout<<1<<endl;
    return 0;
  }
  
  vector<ll> A(200001),B(200001);
  ll a=bit-1,b=bit+1;
  A[0]=1,B[0]=1;
  for(int i=1;i<=n;i++){
    if(a>0) A[i]=A[i-1]*2%a;
    B[i]=B[i-1]*2%b;
  }
  
  ll ansa=0,ansb=0;
  rep(i,n){
    if(x[n-1-i]=='1'){
      if(a>0) ansa=(ansa+A[i])%a;
      ansb=(ansb+B[i])%b;
    }
  } 
  
  for(int i=0;i<n;i++){
    if(bit==1 && i==y){
      cout<<0<<endl;
      continue;
    }
    
    ll ans,cnt=1;
    if(x[i]=='0'){
      ans=(ansb+B[n-1-i])%b;
    }
    else{
      if(a>0) ans=(ansa-A[n-1-i]+a)%a;
    }
    
    while(ans>0){
      cnt++;
      int m=__builtin_popcount(ans);
      ans=ans%m;
    }   
    cout<<cnt<<endl;
  }
  
  return 0;
}