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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;


/**
 *
 * @author Harsh Vardhan Kumar
 */
public class newMain1 {
    static boolean eof = false ;
    static boolean flag = true ;
    
    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new BufferedOutputStream(System.out))), true ) ;
        Reader in = new Reader(new BufferedReader(new InputStreamReader(System.in))) ;
        List<range> arrayList = new ArrayList<>();
        int n = in.nextInt() ;
        int start = 0 ;
        int end = 0 ;
        int[] number = new int[n] ;
        for(int i = 0 ; i<n ; i++) {
            number[i] = in.nextInt() ;
            if(number[i]==0) {
                end = i ;
                //if(end-1>-1) {
                    arrayList.add(new range(start, end)) ;
                //}
                start = end ;
            }
        }
        if(number[n-1]!=0) {
            arrayList.add(new range(start, n-1));
        }
        
        for(range r : arrayList) {
            start = r.start ;
            end = r.end ;
            int as = Integer.MIN_VALUE/2 ;
            int ae  = Integer.MAX_VALUE/2 ;
            if(number[start]==0) {
                start++ ;
                as = start-1 ;
            }
            if(number[end]==0) {
                end-- ;
                ae = end+1 ;
            }
            
            for(int ii = start ; ii<=end ; ii++) {
                number[ii] = Math.min(ii-as, ae-ii) ;
                //System.out.println("ii is "+ii+" number is "+number[ii]);
            }
        }
        for(int k : number) {
            out.print(k+" ");
        }
        out.println();
        //System.out.println(arrayList);
    }
    static class Reader {
        private static BufferedReader b ;
        public static String line ;
        public Reader() {
        }

        public Reader(BufferedReader b) {
            this.b = b ;
        }
        private static StringTokenizer st = null;
        public static String next()  {
            
            if(st==null || !st.hasMoreElements()) {
                try { 
                    line = b.readLine() ;
                    if(line==null) {
                        eof = true ; 
                        return null ;
                    }
                    else {
                        st=new StringTokenizer(line);
                    }
                } catch (IOException ex) {
                    
                }
            }
            return st.nextToken() ;
        }
        public static String nextLine()  {
            try {
                return b.readLine() ;
            } catch (IOException ex) {
                
            }
            return line ;
        }
        public static int nextInt()  {
            return Integer.parseInt(next());
        }
        public static long nextLong()  {
            return Long.parseLong(next());
        }
        public static float nextFloat()  {
            return Float.parseFloat(next());
        }
        public void close() throws IOException {
            b.close() ;
        }
        
    }
    static class range {
        int start ;
        int end ;

        public range(int start, int end) {
            this.start = start;
            this.end = end;
        }
        public String toString() {
            return start+" "+end ;
        }
        
    }
    static class compara implements Comparator<Integer> {

        @Override
        public int compare(Integer o1, Integer o2) {
            return o1-o2 ;
        }
        
    }
}
