console.log((args=>{
  const _ = args.trim().split`\n`;
  const N = _[0]|0, X = _[1].split``.map(v=>v|0);
  function popcount(n) {
    n = (n&0x55555555) + (n>>1&0x55555555);
    n = (n&0x33333333) + (n>>2&0x33333333);
    n = (n&0x0f0f0f0f) + (n>>4&0x0f0f0f0f);
    n = (n&0x00ff00ff) + (n>>8&0x00ff00ff);
    return (n&0x000ffff) + (n>>16);
  }
  let pc = 0;
  for ( let i = 0; i < N; i++ ) if ( X[i]|0 ) pc++;
  const pcp = pc+1, pcm = pc-1;
  let xpp = 0, xpm = 0;
  for ( let i = 0; i < N; i++) {
    xpp = ((xpp<<1) + X[i]) % pcp;
    xpm = ((xpm<<1) + X[i]) % pcm;
  }
  const o = Array(N).fill(1);
  let bp = 1, bm = pcm-1;
  for ( let i = N; i--;) {
    let n = 0;
    if ( !X[i] ) n = (xpp + bp)%pcp;
    else if ( pcm > 0 ) n = (xpm + bm)%pcm;
    else o[i] = 0;
    while(n) {
      n %= popcount(n);
      o[i]++;
    }
    bp = (bp*2) % pcp;
    bm = (bm*2) % pcm;
  }
  return o.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
