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) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream("dijkstra.in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream("dijkstra.out");


//        Path path = Paths.get(URI.create("file:///foo/bar/Main.java"));
//        System.out.print(path.getName(200));

//        Path p = Paths.get("/foo/bar/Main.java");
//        for (Path e : p) {
//            System.out.println(e);
//        }

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private final int INF = (int) (1e9 + 7);

    public void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();

        int[] a = new int[n];
        List<Integer> posZero = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            if (a[i] == 0) {
                posZero.add(i);
            }
        }

//        for (int i = 0; i < posZero.size(); i++) {
//            out.print(posZero.get(i) + " ");
//        }
//        out.println();

        int izero = 0;
        for (int i = 0; i < n; i++) {
            if (izero == posZero.size()) {
                int pos = i - posZero.get(izero - 1);
                out.print(pos + " ");
                continue;
            }
            if (izero == 0) {
                int pos = posZero.get(izero) - i;
                out.print(pos + " ");
                if (i == posZero.get(izero)) {
                    izero++;
                }
                continue;
            }

            if (i == posZero.get(izero)) {
                out.print("0 ");
                izero++;
                continue;
            }
//            out.println((i - posZero.get(izero - 1)) + ", " + (posZero.get(izero) - i));
            int pos = Math.min(i - posZero.get(izero - 1), posZero.get(izero) - i);
            out.print(pos + " ");
        }
        out.println();
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    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());
    }
}
