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 
/*      MOHD SADIQ        */


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.ArrayList;

public class Main {

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

    private  long longVal() throws IOException{
        return Long.parseLong(br.readLine().trim());
    }
    private  int intVal() throws IOException{
        return Integer.parseInt(br.readLine().trim());
    }
    private  double doubleVal() throws IOException{
        return Double.parseDouble(br.readLine().trim());
    }
    private  int[] intArr() throws IOException{
        String[] s = br.readLine().trim().split(" ");
        int n = s.length;
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        return a;
    }
    private  long[] longArr() throws IOException {
        String[] s = br.readLine().trim().split(" ");
        int n = s.length;
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(s[i]);
        }
        return a;
    }
    private  double[] doubleArr() throws IOException {
        String[] s = br.readLine().trim().split(" ");
        int n = s.length;
        double[] a = new double[n];
        for (int i = 0; i < n; i++) {
            a[i] = Double.parseDouble(s[i]);
        }
        return a;
    }
    private String[] stringArr() throws IOException{
        String[] s = br.readLine().trim().split(" ");
        return s;
    }
    private  char[] charArr() throws IOException{
        return br.readLine().trim().toCharArray();
    }

    private static String solve() throws IOException {

        Main obj = new Main();
        int n = obj.intVal();
        int[] a = obj.intArr();

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

        int l = n-1,r = n-1;
        StringBuffer ans = new StringBuffer();
        if(al.size()==1) {
            for(int i=0;i<n;i++){
                ans.append(Math.abs(i-al.get(0))+" ");
            }
            return new String(ans);
        }
        r = al.get(0);
        int ind = 0;
        for(int i=0;i<n;i++){
            if(i>=r){
                l = r;
                if(al.size()-1>ind){
                    ind ++;
                    r = al.get(ind);
                }
//                System.out.println(l+" "+r+" "+a[i]);
            }
//            if(a[i]==0){
//                l = r;
//                r = i;
//            }
            a[i] = Math.min(Math.abs(l-i),Math.abs(r-i));
            ans.append(a[i]+" ");
        }

        return ""+ans;

    }


    public static void main(String[] args) throws IOException {
        Main ob = new Main();
//        int total_test_case = ob.intVal();
        int total_test_case = 1;
        StringBuffer ans = new StringBuffer();
        String k ;
        for(int test_case =0;test_case<total_test_case;test_case++){
            k = Main.solve();
//            System.out.println(k);
            ans.append(k+"");
        }
        System.out.print(ans);
    }
}