def harderPuzzle(n, puzzle):
stack=[]
ans=[]
stack.append(n-1)
ans.append(0)
for i in range(n-2,-1,-1):
while len(stack)!=0 and puzzle[stack[-1]]<=puzzle[i]:
stack.pop()
if len(stack)==0:
ans.append(0)
else:
ans.append(stack[-1]-i)
stack.append(i)
return ans[::-1]



