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.io.*;
import java.util.*;
import java.math.*;

public final class dis_to_zero
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();int[] a=new int[n],dis=new int[n];
		
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();dis[i]=Integer.MAX_VALUE;
		}
		
		int pos=-1;
		
		for(int i=0;i<n;i++)
		{
			if(a[i]==0)
			{
				pos=i;
			}
			
			if(pos != -1)
			{
				dis[i]=i-pos;
			}
		}
		
		pos=-1;
		
		for(int i=n-1;i>=0;i--)
		{
			if(a[i]==0)
			{
				pos=i;
			}
			
			if(pos != -1)
			{
				dis[i]=Math.min(dis[i],pos-i);
			}
		}
		
		for(int i=0;i<n;i++)
		{
			out.print(dis[i]+" ");
		}
		
		out.println("");out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}