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 
# python2
import sys
import os.path
import heapq
import collections
import math 
import bisect

def binary_search(x,list1,low,high):
    if low > high or x >list1[high] or x < list1[low] :
        return -1
    mid = ((high+low)/2)
    if list1[mid] == x:
        return mid
    elif list1[mid] > x:
        return binary_search(x,list1,low,mid-1)
    elif list1[mid] < x:
        return binary_search(x,list1,mid+1,high)
def main():
    if os.path.exists('input.txt'):
        input = open('input.txt', 'r')
    else:
        input = sys.stdin
    #--------------------------------INPUT---------------------------------
    n = list(map(int, input.readline().split()))
    lis1 = list(map(int, input.readline().split()))
    zeros = list()
    for i in range(len(lis1)):
        if lis1[i] ==0:
            zeros.append(i)
    #print zeros
    res = []
    for i,x in enumerate(lis1):
        if bisect.bisect_left(zeros, i)>0:
            myi = min(abs(i-zeros[min(bisect.bisect_left(zeros, i),len(zeros)-1)]),abs(i-zeros[min(bisect.bisect_left(zeros, i)-1,len(zeros)-1)]))
        else:
            myi = abs(i-zeros[bisect.bisect_left(zeros, i)])
        res.append(myi)
    
    #print bisect.bisect(zeros, 6)
    output = ' '.join(map(str, res))
    #-------------------------------OUTPUT----------------------------------
    if os.path.exists('output.txt'):
        open('output.txt', 'w').writelines(str(output))
    else:
        sys.stdout.write(str(output))


if __name__ == "__main__":
    main()

