n,*x=map(int,open(0).read().split())
d=[0]+[10**9]*~-n
l=x[n]
i=t=0
for j,y in enumerate(x[1:n],1):
    t=y-x[i]
    while t>l:
        i+=1
        t=y-x[i]
    print(i,j,t)
    d[j]=d[i]+1
for a,b in zip(x[n+2::2],x[n+3::2]):
    print(abs(d[a-1]-d[b-1])or 1)