n = int(input())
a = input().split(' ')
for i in range(len(a)):
    a[i] = int(a[i])
q = int(input())
 
otv = []
fast = {}
 
def f(i):
    if n - i - int(a[i-1]) < 0:
        fast[i] = abs(n - i - int(a[i-1]))
    else:
        fast[i] = int(a[i-1]) + i
    if fast[i] == 0:
        fast[i] = i

ss = map(f, range(1, n+1))
for i in ss:
    pass
 
for i in range(q):
    s, k = input().split(' ')
    s, k = int(s), int(k)
    for j in range(k):
        s = fast[s]
    otv.append(str(s))
 
print(' '.join(otv))
