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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.invoke.MethodHandles;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

    static class FastScanner {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Integer[] readArrayInt(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

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

    static class Pair {

        int first;

        int second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            Pair pair = (Pair) o;
            return first == pair.first && second == pair.second;
        }

        @Override
        public int hashCode() {
            return Objects.hash(first, second);
        }
    }

    static class Equation {

        // ax+by=c;
        int a, b, c;

        public Equation(int x1, int y1, int x2, int y2) {
            int a = y2 - y1;
            int b = x1 - x2;
            int c = a * x1 + b * y1;
        }

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

        public boolean isPointOnLine(int x, int y) {
            return a * x + b * y == c;
        }
    }

    private static void buildGraph(HashMap<Integer, Set<Integer>> map, int first, int second) {
        Set<Integer> set = map.getOrDefault(first, new HashSet<>());
        set.add(second);
        map.put(first, set);
        set = map.getOrDefault(second, new HashSet<>());
        set.add(first);
    }

    public static void parseAndGenerate() {
    }

    static void printArray(int[] arr, PrintWriter out) {
        for (int i = 0; i < arr.length; i++) {
            out.print(arr[i] + " ");
        }
        out.println();
    }

    public static void main(String[] args) {
        parseAndGenerate();
        try (PrintWriter out = new PrintWriter(System.out)) {
            FastScanner scanner = new FastScanner();
            int n = scanner.nextInt();
            int[] arr = scanner.readArray(n);
            int[] right = new int[n];
            Arrays.fill(right, -1);
            right[n - 1] = (arr[n - 1] == 0 ? n - 1 : -1);
            for (int i = arr.length - 2; i >= 0; i--) {
                if (arr[i] == 0) {
                    right[i] = i;
                } else {
                    right[i] = right[i + 1];
                }
            }
            int last = -1;
            int[] ans = new int[n];
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == 0) {
                    last = i;
                    ans[i] = 0;
                } else if (last >= 0 && i + 1 < right.length && right[i + 1] != -1) {
                    ans[i] = Math.min(i - last, right[i + 1] - i);
                } else if (last < 0 && i + 1 < right.length && right[i + 1] != -1) {
                    ans[i] = right[i + 1] - i;
                } else if (last >= 0) {
                    ans[i] = i - last;
                }
            }
            printArray(ans, out);
        }
    }
}
