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.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }
    static class Solver {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] st = new int[n];
            List<Integer> l = new ArrayList<>();
            for (int i = 0; i < n; ++i) {
                int t = st[i] = in.nextInt();
                if (i == 0) {
                    l.add(t);
                } else if (l.get(l.size() - 1) != t || (l.get(l.size() - 1) == t && t != 0)) {
                    l.add(t);
                }
            }
            int[] a = new int[l.size()];
            int[] min = new int[a.length];
            Arrays.fill(min, (int)1e9 + 1);
            List<Integer> indices = new ArrayList<>();
            for (int i = 0; i < l.size(); ++i) {
                a[i] = l.get(i);
                if (a[i] == 0) {
                    min[i] = 0;
                    indices.add(i);
                }
            }
            n = a.length;
            for (Integer i : indices) {
                int ind = i - 1;
                int t = 0;
                while (ind >= 0 && a[ind] != 0) {
                    ++t;
                    min[ind] = Math.min(min[ind], t);
                    --ind;
                }
                ind = i + 1;
                t = 0;
                while (ind < n && a[ind] != 0) {
                    ++t;
                    min[ind] = Math.min(min[ind], t);
                    ++ind;
                }
            }
            int[] fin = new int[st.length];
            int ind = 0;
            for (int i = 0; i < fin.length; ++i) {
                if (ind < n && st[i] == a[ind]) {
                    fin[i] = min[ind++];
                }
            }
            for (int t : fin) {
                out.print(t + " ");
            }
        }
    } // wubba lubba dub dub
    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.hasMoreElements()) {
                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());
        }
    }
}