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.Scanner;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author David Wu
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        private static ArrayList<Integer> list;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            TaskB.FastScanner sc = new TaskB.FastScanner();

            int n = Integer.parseInt(sc.nextLine());
            list = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                list.add(sc.nextInt());
            }

            ArrayList<Integer> zeros = indexOfAll(0, list);

            Collections.sort(zeros);

            for (int k = 0; k < list.size(); k++) {
                int t = Collections.binarySearch(zeros, k);
                if (t < 0) {
                    t += 1;
                    t = -t;
                }
                if (t + 1 > zeros.size()) {
                    out.print(k - zeros.get(zeros.size() - 1) + " ");
                    continue;
                }
                if (t != 0) {
                    if (zeros.get(t) - k < k - zeros.get(t - 1)) {
                        out.print(zeros.get(t) - k + " ");
                    } else {
                        out.print(k - zeros.get(t - 1) + " ");
                    }
                } else {
                    out.print(zeros.get(t) - k + " ");
                }

            }

        }

        static ArrayList<Integer> indexOfAll(Object obj, ArrayList list) {
            ArrayList<Integer> indexList = new ArrayList<Integer>();
            for (int i = 0; i < list.size(); i++)
                if (obj.equals(list.get(i)))
                    indexList.add(i);
            return indexList;
        }

        public static class FastScanner {
            BufferedReader br;
            StringTokenizer st;

            public FastScanner() {
                br = new BufferedReader(new InputStreamReader(System.in));
            }

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

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

            String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str;
            }

        }

    }
}

