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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class First {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int t;
        //t = in.nextInt();
        t = 1;
        while (t > 0) {
            solver.call(in,out);
            t--;
        }
        out.close();
    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            int n;
            n = in.nextInt();

            int[] arr = new int[n];
            ArrayList<Integer> arrayList = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                if(arr[i] == 0){
                    arrayList.add(i);
                }
            }

            int l, r, mid;

            for (int i = 0; i < n; i++) {
                if (arr[i] == 0) {
                    out.print(0 + " ");
                    continue;
                }

                if (i == 0) {
                    out.print(Math.abs(arrayList.get(0) - i ) + " ");
                }
                else if (i == n - 1) {
                    out.print(Math.abs(arrayList.get(arrayList.size()-1) - i ) + " ");
                }
                else {
                    l = -1;
                    r = arrayList.size();
                    while(l+1<r){
                        mid = (l+r)/2;

                        if(arrayList.get(mid)<=i){
                            l = mid;
                        }
                        else
                            r = mid;

                        //System.out.println(l+" "+r+" "+i);
                        // -1 0 1

                    }

                    if(l==-1){
                        out.print(Math.abs(i-arrayList.get(0))+" ");
                    }
                    else if(l==arrayList.size()-1) {
                        out.print(Math.abs(i-arrayList.get(l))+" ");
                    }
                    else{
                        out.print(Math.min(i - arrayList.get(l), arrayList.get(l + 1) - i) + " ");
                    }

                }
            }
        }
    }

    static class answer implements Comparable<answer> {
        int a, b;

        public answer(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(answer o) {
            if(o.a==this.a){
                return this.b- o.b;
            }
            return o.a - this.a;
        }
    }

    static long gcd(long a, long b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static void sort(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static final Random random=new Random();

    static void shuffleSort(int[] arr) {
        int n=arr.length;
        for (int i=0; i<n; i++) {
            int a=random.nextInt(n), temp=arr[a];
            arr[a]=arr[i];
            arr[i]=temp;
        }
        Arrays.sort(arr);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}