You are given an array a consisting of n integers. In one move, you can jump from the position i to the position i - a_i (if 1 ≤ i - a_i) or to the position i + a_i (if i + a_i ≤ n).

For each position i from 1 to n you want to know the minimum the number of moves required to reach any position j such that a_j has the opposite parity from a_i (i.e. if a_i is odd then a_j has to be even and vice versa).

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in a.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n), where a_i is the i-th element of a.

Output

Print n integers d_1, d_2, ..., d_n, where d_i is the minimum the number of moves required to reach any position j such that a_j has the opposite parity from a_i (i.e. if a_i is odd then a_j has to be even and vice versa) or -1 if it is impossible to reach such a position.

Example

Input


10
4 5 7 6 7 5 4 4 6 4


Output


1 1 1 2 -1 1 1 3 1 1 
"""n=int(input())
s=[int(x) for x in input().split()]


L=[]
for i in range(0,n):
    h=[]
    L.append(h)

for i in range(0,len(s)):
    if(i-s[i]>=0 and i-s[i]<n):
        L[i].append(i-s[i])
    if(i+s[i]>=0 and i+s[i]<n):
        L[i].append(i+s[i])



global ans
ans=-1

global flag
flag=0

vis1=[False]*n
vis2=[False]*n
fnl=[-1]*n

def dfs1(u,parity,dis):
    vis1[u]=True
    if(s[u]%2==parity):
        global ans
        ans=dis
        return
    for i in L[u]:
        if(vis1[i]==False):
            dfs(i,parity,dis+1)


def dfs2(u,parity,dis):
    vis2[u]=True
    if(s[u]%2==parity):
        global ans
        ans=dis
        return
    for i in L[u]:
        if(vis2[i]==False):
            dfs(i,parity,dis+1)

for i in range(0,len(s)):
    if(vis2[i]==False):
        global ans
        ans=-1
        if(s[i]%2==0):
            dfs1(i,1,0)
            dfs2(i,1,psd)
        else:
            dfs1(i,0,0)
            dfs2(i,0,psd)"""


"""from collections import deque

n=int(input())
s=[int(x) for x in input().split()]


L=[]
for i in range(0,n):
    h=[]
    L.append(h)

for i in range(0,len(s)):
    if(i-s[i]>=0 and i-s[i]<n):
        L[i].append(i-s[i])
    if(i+s[i]>=0 and i+s[i]<n):
        L[i].append(i+s[i])



global ans
ans=-1


#vis1=[False]*n
vis2=[False]*n
fnl=[-1]*n


for i in range(0,len(s)):
    if(vis2[i]==False):
        

        des=i
        #global ans
        ans=-1

        q=deque()

        pred=[-1]*n
        vis1=[False]*n

        if(s[i]%2==0):
            q.append((i,1,0))
        else:
            q.append((i,0,0))

        while(q):

            r=q.popleft()
            vis1[r[0]]=True
           

            if(s[r[0]]%2==r[1]):
                #global ans
                ans=r[2]
                des=r[0]
                break

            for i in L[r[0]]:
                if(vis1[i]==False):
                    pred[i]=r[0]
                    q.append((i,r[1],r[2]+1))


        if(ans==-1):
            
            q=deque()

            #pred=[-1]*n
            #vis1=[False]*n

            if(s[i]%2==0):
                q.append((i,1,0))
            else:
                q.append((i,0,0))

            while(q):

               r=q.popleft()
               vis2[r[0]]=True

               fnl[r[0]]=-1

               for i in L[r[0]]:
                   
                   
                   if(vis1[i]==False):
                       
                       #pred[i]=u
                       q.append((i,r[1],r[2]+1))

        else:
            path=[des]
            while(pred[des]!=-1):
                path.append(pred[des])
                des=pred[des]

            tot=ans
            for i in range(len(path)-1,0,-1):
                fnl[path[i]]=tot
                vis2[path[i]]=True
                tot-=1


print(*fnl)"""


from collections import deque

n=int(input())
s=[int(x) for x in input().split()]


L=[]
for i in range(0,n):
    h=[]
    L.append(h)

for i in range(0,len(s)):
    if(i-s[i]>=0 and i-s[i]<n):
        L[i-s[i]].append(i)
    if(i+s[i]>=0 and i+s[i]<n):
        L[i+s[i]].append(i)

fnl=[-1]*n

q=deque()

dist=[10000000007]*n

for i in range(0,len(s)):
    if(s[i]%2!=0):
        q.append(i)
        dist[i]=0



while(q):
    r=q.popleft()

    """if(s[r]%2==0 and dist[r]!=10000000007):
        #if(r[0]==0):
            #print(r)
        fnl[r]=dist[r]"""


    for i in L[r]:
        if(dist[i]==10000000007):
            dist[i]=dist[r]+1
            q.append(i)

for i in range(0,len(s)):
    if(s[i]%2==0 and dist[i]!=10000000007):
        fnl[i]=dist[i]
        



q.clear()

dist=[10000000007]*n

for i in range(0,len(s)):
    if(s[i]%2==0):
        q.append(i)
        dist[i]=0



while(q):
    r=q.popleft()

    """if(s[r]%2==0):
        #if(r[0]==0):
            #print(r)
        fnl[r]=dist[r]"""


    for i in L[r]:
        if(dist[i]==10000000007):
            dist[i]=dist[r]+1
            q.append(i)

for i in range(0,len(s)):
    if(s[i]%2!=0 and dist[i]!=10000000007):
        fnl[i]=dist[i]

print(*fnl)
            


                
            


            

        
        
        
        
    

        
        
        
        
    
