You are given the array of integer numbers a0, a1, ..., an - 1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — length of the array a. The second line contains integer elements of the array separated by single spaces ( - 109 ≤ ai ≤ 109).

Output

Print the sequence d0, d1, ..., dn - 1, where di is the difference of indices between i and nearest j such that aj = 0. It is possible that i = j.

Examples

Input

9
2 1 0 3 0 0 3 2 4


Output

2 1 0 1 0 0 1 2 3 

Input

5
0 1 2 3 4


Output

0 1 2 3 4 

Input

7
5 6 0 1 -2 3 4


Output

2 1 0 1 2 3 4 
import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
 
public class M
{	
	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		
		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}
		
		public int read()
		{
			if (numChars==-1) 
				throw new InputMismatchException();
			
			if (curChar >= numChars)
			{
				curChar = 0;
				try 
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				
				if(numChars <= 0)				
					return -1;
			}
			return buf[curChar++];
		}
	 
		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();
			
			while(isSpaceChar(c)) 
				c = read();
			
			int sgn = 1;
			
			if (c == '-') 
			{
				sgn = -1;
				c = read();
			}
			
			int res = 0;
			do 
			{
				if(c<'0'||c>'9') 
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c)); 
			
			return res * sgn;
		}
		
		public long nextLong() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') 
			{
				sgn = -1;
				c = read();
			}
			long res = 0;
			
			do 
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}
		
		public double nextDouble() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') 
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') 
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') 
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) 
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
		
		public String readString() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do 
			{
				res.appendCodePoint(c);
				c = read();
			} 
			while (!isSpaceChar(c));
			
			return res.toString();
		}
	 
		public boolean isSpaceChar(int c) 
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	 
		public String next() 
		{
			return readString();
		}
		
		public interface SpaceCharFilter 
		{
			public boolean isSpaceChar(int ch);
		}
	}
	
	static class Node implements Comparable<Node>
	{
		long key;
		long value;
		long double_value;
		
		public Node(long key , long value , long double_value)
		{
			this.key = key;
			this.value = value;
			this.double_value = double_value;
		}
		
		public int compareTo(Node node)
		{
			if(double_value < node.double_value)
				return 1;
			else if(double_value > node.double_value)
				return -1;
			
			return 0;
		}
	}
	
	public static int prime[] = new int[1000007];

	public static void Prime_Factors()
	{
		for(int i = 0 ; i < 1000001 ; i++)
			prime[i] = 1;

		prime[0] = 0;
		prime[1] = 0;

		for(int i = 2 ; i*i < 100001 ; i++)
		{
			if(prime[i] == 1)
			{
				for(int j = i*i ; j < 100001 ; j += i)
				{
					prime[j] = 0;
				}
			}
		}
	}
	
	public static void main(String args[]) throws Exception
	{	
		InputReader In = new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);
		
		int n = In.nextInt();
		
		int arr[] = new int[n];
		
		int A[] = new int[n];
		
		for(int i = 0 ; i < n ; i++)
		{
			arr[i] = In.nextInt();
		}
		
		Arrays.fill(A , Integer.MAX_VALUE);
		
		for(int i = 0 ; i < n ; )
		{
			if(arr[i] == 0)
			{
				A[i] = 0;
				
				for(int j = i-1 , count = 1; ; j-- , count++)
				{
					if(j >= 0 && A[j] > count)
						A[j] = count;
					else
						break;
				}
				
				int j = i+1 , count = 1;
				
				for(j = i+1 ; ; j++ , count++)
				{
					if(j < n && A[j] > count && arr[j] != 0)
						A[j] = count;
					else
						break;
				}
				
				i = j;
			}
			else
				i++;
		}
		
		for(int i = 0 ; i < n ; i++)
			w.print(A[i] + " ");
		
		w.close();
	}
}