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.ArrayDeque;
    import java.util.Arrays;
    import java.util.InputMismatchException;
    import java.util.Queue;
    import java.io.*;
    import java.lang.reflect.Array;
    import java.math.BigInteger;
    import java.util.*;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.util.Collections;
    import java.io.InputStreamReader;
    import java.util.logging.SimpleFormatter;


        public class Main1 {







            public static void main(String[] args) {

                try {


                    FastScanner in = new FastScanner();
                    PrintWriter out = new PrintWriter(System.out);

                   ArrayList<Integer> list = new ArrayList<>() ;
                   int n = in.nextInt() ;
                   int a[] = in.readArray(n) ;
                   int left[] = new int[n] ;
                   int right[] = new int[n] ;

                   int temp = 10000000 ;
                    for (int i = 0; i <n ; i++) {
                        if (a[i] == 0){
                            temp = i ;
                            left[i] = temp ;
                        }
                        else left[i] = temp ;
                    }
                    temp = 10000000 ;
                    for (int i=n-1 ; i>=0 ; i--){
                        if (a[i] == 0){
                            temp = i ;
                            right[i] = temp ;
                        }
                        else right[i] = temp ;

                    }

                    for (int i = 0; i <n ; i++) {
                        out.append( (    Math.min( Math.abs(i - right[i]) , Math.abs(i - left[i]))  ) + " ") ;
                    }






                    out.flush();
                    out.close();
                }
                catch (Exception e){
                    return;
                }
            }


            private static int countDigits(long l) {
                if (l >= 1000000000000000000L) return 19;
                if (l >= 100000000000000000L) return 18;
                if (l >= 10000000000000000L) return 17;
                if (l >= 1000000000000000L) return 16;
                if (l >= 100000000000000L) return 15;
                if (l >= 10000000000000L) return 14;
                if (l >= 1000000000000L) return 13;
                if (l >= 100000000000L) return 12;
                if (l >= 10000000000L) return 11;
                if (l >= 1000000000L) return 10;
                if (l >= 100000000L) return 9;
                if (l >= 10000000L) return 8;
                if (l >= 1000000L) return 7;
                if (l >= 100000L) return 6;
                if (l >= 10000L) return 5;
                if (l >= 1000L) return 4;
                if (l >= 100L) return 3;
                if (l >= 10L) return 2;
                return 1;
            }






            static void updateRangeLazy(int tree[] , int lazy[] , int ss ,int se , int l , int r , int increment , int index){

                if (lazy[index] != 0 ){
                    tree[index] += lazy[index];

                    if (ss != se){
                        lazy[2*index]  +=  lazy[index];
                        lazy[2*index + 1]  +=  lazy[index];
                    }
                    lazy[index ] = 0 ;
                }

                if (ss > r && se< l )
                    return;

                if (ss >= l && se <= r) {
                    tree[index] += increment;


                    if (ss != se) {
                        lazy[2 * index] += increment;
                        lazy[2 * index + 1] += increment;
                    }
                    return;
                }

                int mid = (ss + se)/2 ;


                tree[index] =  Math.min( tree[2*index], tree[2*index + 1] ) ;

            }




            static class FastOutput implements AutoCloseable, Closeable, Appendable {
                private static final int THRESHOLD = 32 << 10;
                private final Writer os;
                private StringBuilder cache = new StringBuilder(THRESHOLD * 2);

                public FastOutput append(CharSequence csq) {
                    cache.append(csq);
                    return this;
                }

                public FastOutput append(CharSequence csq, int start, int end) {
                    cache.append(csq, start, end);
                    return this;
                }

                private void afterWrite() {
                    if (cache.length() < THRESHOLD) {
                        return;
                    }
                    flush();
                }

                public FastOutput(Writer os) {
                    this.os = os;
                }

                public FastOutput(OutputStream os) {
                    this(new OutputStreamWriter(os));
                }

                public FastOutput append(char c) {
                    cache.append(c);
                    afterWrite();
                    return this;
                }

                public FastOutput append(long c) {
                    cache.append(c);
                    afterWrite();
                    return this;
                }

                public FastOutput append(String c) {
                    cache.append(c);
                    afterWrite();
                    return this;
                }

                public FastOutput println() {
                    return append(System.lineSeparator());
                }

                public FastOutput flush() {
                    try {
    //            boolean success = false;
    //            if (stringBuilderValueField != null) {
    //                try {
    //                    char[] value = (char[]) stringBuilderValueField.get(cache);
    //                    os.write(value, 0, cache.length());
    //                    success = true;
    //                } catch (Exception e) {
    //                }
    //            }
    //            if (!success) {
                        os.append(cache);
    //            }
                        os.flush();
                        cache.setLength(0);
                    } catch (IOException e) {
                        throw new UncheckedIOException(e);
                    }
                    return this;
                }

                public void close() {
                    flush();
                    try {
                        os.close();
                    } catch (IOException e) {
                        throw new UncheckedIOException(e);
                    }
                }

                public String toString() {
                    return cache.toString();
                }

            }







            static class FastScanner {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st = new StringTokenizer("");

                String next() {
                    while (!st.hasMoreTokens())
                        try {
                            st = new StringTokenizer(br.readLine());
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    return st.nextToken();
                }

                int nextInt() {
                    return Integer.parseInt(next());
                }

                int[] readArray(int n) {
                    int[] a = new int[n];
                    for (int i = 0; i < n; i++) a[i] = nextInt();
                    return a;
                }


                long nextLong() {
                    return Long.parseLong(next());
                }
            }


        }







