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

/*
 *
http://codeforces.com/contest/803/problem/B
9
2 1 0 3 0 0 3 2 4
выходные данные
2 1 0 1 0 0 1 2 3
*/
public class Main {

    private FastScanner sc;
    private PrintWriter out;

    static int inf = 1_000_000_000;
    static int maxn = 200005;

    int[] a     = new int[maxn];
    int[] left  = new int[maxn];
    int[] right = new int[maxn];

    public void solve() {

        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }

        /*for (int i=0; i<n; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println();*/


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

        /*for (int i=0; i<=n; i++) {
            System.out.print(left[i] + " ");
        }*/

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


        //left  = goLeft(a);
        //right = goRight(a);

        for (int i=1; i<=n; i++) {
            System.out.print( Math.min(left[i], right[i]) + " ");
        }

    }


    private void run() {
        /*try {
            sc = new FastScanner(new File("input.txt"));
            out = new PrintWriter(new File("output.txt"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }*/

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

        solve();

        out.close();

    }



    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }


    public static void main(String[] args) {
        new Main().run();
    }
}
