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 
/*
 * For the brave souls who get this far: You are the chosen ones,
 * the valiant knights of programming who toil away, without rest,
 * fixing our most awful code. To you, true saviors, kings of men,
 * I say this: never gonna give you up, never gonna let you down,
 * never gonna run around and desert you. Never gonna make you cry,
 * never gonna say goodbye. Never gonna tell a lie and hurt you.
 * 
 * And Logic is the strongest weapon. 
 *
 */
//package Coding;

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.Entry;

public class Coding {

    private static InputStream stream;
    private static byte[] buf = new byte[1024];
    private static int curChar;
    private static int numChars;
    private static SpaceCharFilter filter;
    private static PrintWriter pw;
    //pw.print("Case #" + i + ": ");
    //private static int infi = (int) 1e9;
    //private static final int N = 1234567;
    //private static final double MOD = 1e9 + 9;
    //Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

    public static int soln() {
        int n = nI();
        int[] a = new int[n];
        int[] l = new int[n];
        int[] r = new int[n];
        //Arrays.fill(l, Integer.MIN_VALUE);
        //Arrays.fill(r, Integer.MIN_VALUE);
        int x = (int) 1e6 * -1;
        for (int i = 0; i < n; i++) {
            a[i] = nI();
            if (a[i] == 0) {
                x = i;
            }
            l[i] = i - x;
        }
        x = (int) 1e6;
        for (int i = n - 1; i >= 0; i--) {
            if (a[i] == 0) {
                x = i;
            }
            r[i] = x - i;
        }
        //pIArr(l);
        //pIArr(r);
        for (int i = 0; i < n; i++) {
            pw.print(Math.min(l[i], r[i]) + " ");
        }
        return 0;
    }

    public static void main(String[] args) throws FileNotFoundException {
        InputReader(System.in);
        //pw = new PrintWriter(new FileOutputStream("ans.txt"));
        //pw = new PrintWriter(new FileOutputStream("ans1.txt"));
        pw = new PrintWriter(System.out);
        soln();
        pw.close();
    }

    /*
     *********************************************************************************************
     */
    public static void InputReader(InputStream stream1) {
        stream = stream1;
    }

    private static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private static boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    private static int read() {
        if (numChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    private static void pIArr(int[] man) {
        int l = man.length;
        for (int i = 0; i < l; i++) {
            pw.print(man[i] + " ");
        }
        pw.println();
    }

    private static void pCArr(char[] man) {
        int l = man.length;
        for (int i = 0; i < l; i++) {
            pw.print(man[i] + " ");
        }
        pw.println();
    }

    private static void pLArr(long[] man) {
        int l = man.length;
        for (int i = 0; i < l; i++) {
            pw.print(man[i] + " ");
        }
        pw.println();
    }

    private static void pDArr(double[] man) {
        int l = man.length;
        for (int i = 0; i < l; i++) {
            pw.print(man[i] + " ");
        }
        pw.println();
    }

    private static double nD() {
        return Double.parseDouble(nS());
    }

    private static int nI() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static long nL() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static String nS() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private static String nLi() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    private static boolean isSpaceChar(int c) {
        if (filter != null) {
            return filter.isSpaceChar(c);
        }
        return isWhitespace(c);
    }

    private interface SpaceCharFilter {

        public boolean isSpaceChar(int ch);
    }
}
