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.math.*;
    	    import java.util.*;
    	    import javax.print.attribute.SetOfIntegerSyntax;
    	     
    	    public class Main {
    	    	private static InputStream stream;
    	    	private static byte[] buf = new byte[1024];
    	    	private static int curChar;
    	    	private static int numChars;
    	    	private static SpaceCharFilter filter;
    	    	private static PrintWriter pw;
    	    	private static long count = 0,mod=1000000007;
    	    	private static TreeSet<Integer>ts[]=new TreeSet[200000];
    	    	private static HashSet hs=new HashSet();
    	     
     
    	    	 public static void main(String[] args) {
    		        	InputReader(System.in);
    		    		pw = new PrintWriter(System.out); 
    		            new Thread(null ,new Runnable(){
    		               public void run(){
    		                   try{
    		                       soln();
    		                       pw.close();
    		                   } catch(Exception e){
    		                       e.printStackTrace();
    		                   }
    		               }
    		           },"1",1<<26).start();
    		       }
    	     
    	     
    	    	public static long gcd(long x, long y) {
    	    		if (x == 0)
    	    			return y;
    	    		else
    	    			return gcd( y % x,x);
    	    	}
    	    	
    	    	 
    	    	// To Get Input
    	    	// Some Buffer Methods
    	     
    	    	public static void InputReader(InputStream stream1) {
    	    		stream = stream1;
    	    	}
    	     
    	    	private static boolean isWhitespace(int c) {
    	    		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    	    	}
    	     
    	    	private static boolean isEndOfLine(int c) {
    	    		return c == '\n' || c == '\r' || c == -1;
    	    	}
    	     
    	    	private static 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++];
    	    	}
    	     
    	    	private static 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;
    	    	}
    	     
    	    	private static 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;
    	    	}
    	     
    	    	private static String nextToken() {
    	    		int c = read();
    	    		while (isSpaceChar(c))
    	    			c = read();
    	    		StringBuilder res = new StringBuilder();
    	    		do {
    	    			res.appendCodePoint(c);
    	    			c = read();
    	    		} while (!isSpaceChar(c));
    	    		return res.toString();
    	    	}
    	     
    	    	private static String nextLine() {
    	    		int c = read();
    	    		while (isSpaceChar(c))
    	    			c = read();
    	    		StringBuilder res = new StringBuilder();
    	    		do {
    	    			res.appendCodePoint(c);
    	    			c = read();
    	    		} while (!isEndOfLine(c));
    	    		return res.toString();
    	    	}
    	     
    	    	private static int[] nextIntArray(int n) {
    	    		int[] arr = new int[n];
    	    		for (int i = 0; i < n; i++) {
    	    			arr[i] = nextInt();
    	    		}
    	    		return arr;
    	    	}
    	     
    	    	private static int[][] next2dArray(int n, int m) {
    	    		int[][] arr = new int[n][m];
    	    		for (int i = 0; i < n; i++) {
    	    			for (int j = 0; j < m; j++) {
    	    				arr[i][j] = nextInt();
    	    			}
    	    		}
    	    		return arr;
    	    	}
    	    	private static char[][] nextCharArray(int n,int m){
    	    		char [][]c=new char[n][m];
    	    		for(int i=0;i<n;i++){
    	    			String s=nextLine();
    	    			for(int j=0;j<s.length();j++){
    	    				c[i][j]=s.charAt(j);
    	    			}
    	    		}
    	    		return c;
    	    	}
    	     
    	    	private static long[] nextLongArray(int n) {
    	    		long[] arr = new long[n];
    	    		for (int i = 0; i < n; i++) {
    	    			arr[i] = nextLong();
    	    		}
    	    		return arr;
    	    	}
    	     
    	    	private static void pArray(int[] arr) {
    	    		for (int i = 0; i < arr.length; i++) {
    	    			pw.print(arr[i] + " ");
    	    		}
    	    		pw.println();
    	    		return;
    	    	}
    	     
    	    	private static void pArray(long[] arr) {
    	    		for (int i = 0; i < arr.length; i++) {
    	    			pw.print(arr[i] + " ");
    	    		}
    	    		pw.println();
    	    		return;
    	    	}
    	     
    	    	private static void pArray(boolean[] arr) {
    	    		for (int i = 0; i < arr.length; i++) {
    	    			pw.print(arr[i] + " ");
    	    		}
    	    		pw.println();
    	    		return;
    	    	}
    	     
    	    	private static boolean isSpaceChar(int c) {
    	    		if (filter != null)
    	    			return filter.isSpaceChar(c);
    	    		return isWhitespace(c);
    	    	}
    	     
    	    	private interface SpaceCharFilter {
    	    		public boolean isSpaceChar(int ch);
    	    	}
    	     
    	    	//----------------------------------------My Code------------------------------------------------//
    	
     
    	    	
    	    	private static void soln() {
    	    	    int n=nextInt();
    	    	    long[] arr=new long[n];
    	    	    int count=0;
    	    	    for(int i=0;i<n;i++){
    	    	    	long t=nextLong();
    	    	    	arr[i]=t;
    	    	    	if(t==0){
    	    	    		count++;
    	    	    	}
    	    	    }
    	    	    int[] xp=new int[count];
    	    	    int t=0;
    	    	    for(int i=0;i<n;i++){
    	    	    	if(arr[i]==0){
    	    	    		xp[t]=i;
    	    	    		t++;
    	    	    	}
    	    	    }
    	    	   
    	    	    int current=0;
    	    	    for(int i=xp[0];i>=0;i--){
    	    	    	arr[i]=current;
    	    	    	current++;
    	    	    }
    	    	    current=0;
    	    	    for(int i=xp[count-1];i<n;i++){
    	    	    	arr[i]=current;
    	    	    	current++;
    	    	    }
    	    	    current=0;
    	    	    if(count>1){
    	    	    	for(int i=0;i<count-1;i++){
    	    	    		int m=(xp[i]+xp[i+1])/2;
    	    	    		for(int j=xp[i];j<=m;j++){
    	    	    	    	arr[j]=current;
    	    	    	    	current++;
    	    	    	    }
    	    	    		current=0;
    	    	    		 for(int j=xp[i+1];j>m;j--){
    	     	    	    	arr[j]=current;
    	     	    	    	current++;
    	     	    	    }
    	    	    		 current=0;
    	    	    	}
    	    	    }
    	    	    for(int i=0;i<n;i++){
    	    	    	pw.print(arr[i]+" ");
    	    	    }
    	    	    
    	    	}
    	    		//-----------------------------------------The End--------------------------------------------------------------------------//
    	    
    	    
    	    	
    	    	
    	 }
    	    	
    	   
    	    
    		class Pair implements Comparable<Pair>{
    		     
    			int x;
    			int y;
    			Pair(int idx,int val){
    				this.x=idx;
    				this.y=val;
    			}
    			@Override
    			public int compareTo(Pair o) {
    				// TODO Auto-generated method stub
    			//	Sort in increasing order
    					if(y>o.y){
    						return -1;
    					}
    					else if(y==o.y){
    						return 0;
    					}
    					else return 1;
                           
    				
    			}
    		
    		}


