using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var X = cin.ReadLine;
			var popc = X.Count(c => c=='1');
			if(popc==1) {
				var uniq1 = X.IndexOf('1');
				if(uniq1==X.Length-1) {
					Console.WriteLine(
						Enumerable.Range(0, N).Select(i => i==N-1 ? 0 : 1)
					.Join("\n"));
				} else {
					Console.WriteLine(
						Enumerable.Range(0, N).Select(i => i==uniq1 ? 0 : i==X.Length-1 ? 2 : 1)
					.Join("\n"));
				}
				return;
			}
			//(1<<(N-i))%(popc+1)
			var tableP = new long[N]; //from MSB
			tableP[N-1]=popc==0 ? 0 : 1;
			for(int i = N-2; i>=0; i--) {
				tableP[i]=tableP[i+1]*2%(popc+1);
			}
			//(1<<(N-i))%(popc-1)
			var tableN = new long[N];
			tableN[N-1]=popc==2 ? 0 : 1;
			for(int i = N-2; i>=0; i--) {
				tableN[i]=tableN[i+1]*2%(popc-1);
			}
			var f1 = new long[N];
			long origP = 0;
			for(int i = 0; i<N; i++) {
				origP=(origP*2+(X[i]=='1' ? 1 : 0))%(popc+1);
			}
			long origN = 0;
			for(int i = 0; i<N; i++) {
				origN=(origN*2+(X[i]=='1' ? 1 : 0))%(popc-1);
			}
			for(int i = 0; i<N; i++) {
				if(X[i]=='1') {
					f1[i]=(origN-tableN[i]+(popc-1))%(popc-1);
				} else {
					f1[i]=(origP+tableP[i]+(popc+1))%(popc+1);
				}
			}
			var c1 = Enumerable.Repeat(1, N).ToArray();
			for(int i = 0; i<N; i++) {
				while(f1[i]!=0) {
					c1[i]++;
					f1[i]%=numofbits5(f1[i]);
				}
			}
			Console.WriteLine(c1.Join("\n"));
		}
		//http://www.nminoru.jp/~nminoru/programming/bitcount.html
		int numofbits5(long bits) {
			bits=(bits&0x55555555)+(bits>>1&0x55555555);
			bits=(bits&0x33333333)+(bits>>2&0x33333333);
			bits=(bits&0x0f0f0f0f)+(bits>>4&0x0f0f0f0f);
			bits=(bits&0x00ff00ff)+(bits>>8&0x00ff00ff);
			return (int)((bits&0x0000ffff)+(bits>>16&0x0000ffff));
		}
	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
	
}


Measured memory_bytes: 36004