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.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

import java.util.StringTokenizer;

 public class Test
 {
     static PrintWriter pw = new PrintWriter(System.out);
     static ArrayList<Integer> list = new ArrayList();
    
    public static void main(String[] args)throws Exception
    {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] ar = new int[n];
        
        for(int i  = 0 ; i<n ; i++)
        {
            ar[i] = Reader.nextInt();
            if(ar[i] == 0)
                list.add(i);
        }
        
        
        StringBuilder res = new StringBuilder();
        
        for(int i = 0 ; i<n ; i++)
        {   
            if(ar[i] == 0)
                res.append("0 ") ;
            else
            {
                int temp = list.size();
                int L = 0;
                int R = list.size() - 1;
                while(L<=R)
                {
                    int mid = (L+R)/2;
                    if(i < list.get(mid))
                    {
                        R = mid - 1;
                        temp = R;
                    }
                    else
                        L = mid +1;
                }
                
   
                if(temp < 0)
                    res.append(list.get(0) - i + " ");
                else if(temp == list.size())
                    res.append(i - list.get(list.size() - 1) + " ");
                else
                    res.append(Math.min(i - list.get(temp), list.get(temp + 1) - i ) + " ");
            }
        }
        
        pw.print(res);
        pw.close();
        
    }
        
}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

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

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}