There is a system of *n* vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to *n*, in the order from the highest to the lowest, the volume of the *i*-th vessel is *a*<sub class="lower-index">*i*</sub> liters.

Initially, all the vessels are empty. In some vessels water is poured. All the water that overflows from the *i*-th vessel goes to the (*i* + 1)-th one. The liquid that overflows from the *n*-th vessel spills on the floor.

Your task is to simulate pouring water into the vessels. To do this, you will need to handle two types of queries:
 1.  Add *x*<sub class="lower-index">*i*</sub> liters of water to the *p*<sub class="lower-index">*i*</sub>-th vessel; 1.  Print the number of liters of water in the *k*<sub class="lower-index">*i*</sub>-th vessel. 
When you reply to the second request you can assume that all the water poured up to this point, has already overflown between the vessels.
The first line contains integer *n* — the number of vessels (1 ≤ *n* ≤ 2·10<sup class="upper-index">5</sup>). The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> — the vessels' capacities (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>). The vessels' capacities do not necessarily increase from the top vessels to the bottom ones (see the second sample). The third line contains integer *m* — the number of queries (1 ≤ *m* ≤ 2·10<sup class="upper-index">5</sup>). Each of the next *m* lines contains the description of one query. The query of the first type is represented as "1 *p*<sub class="lower-index">*i*</sub> *x*<sub class="lower-index">*i*</sub>", the query of the second type is represented as "2 *k*<sub class="lower-index">*i*</sub>" (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*, 1 ≤ *x*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>, 1 ≤ *k*<sub class="lower-index">*i*</sub> ≤ *n*).


# n=int(input())
# l=list(map(int, input().split()))


# q=int(input())
# v=[0 for i in range(n+1)]
# l.append(float('inf'))

# p=[i for i in range(n+1)]
# for i in range(n):
#     p[i]=i+1

# def fill(i,x):
#     t=[]
#     # print(i,x)
#     while v[i]==l[i] :
#         t.append(i)
#         i+=1 
#     while x>0 :
#         pp=min(l[i]-v[i], x)
#         v[i]+=pp 
#         x-=pp 
#         if v[i]==l[i]:
#             t.append(i)
#             i+=1 
#         else:
#             break 
    
#     for child in t:
#         p[child]=i
    
    
# for _ in range(q):
#     t=list(map(int, input().split()))
#     if t[0]==1:
#         fill(t[1]-1, t[2])
#     else:
#         print(v[t[1]-1])
        
from sys import stdin, stdout


def find_next(v):
    q = v
    while indexes[q] != q:
        q = indexes[q]
    while v != q:
        indexes[v], v = q, indexes[v]
    return v


input = stdin.readline
n = int(input())
a = tuple(map(int, input().split()))
indexes = [i for i in range(n + 1)]
res = [0] * (n + 1)
for _ in range(int(input())):
    req = input().split()
    if req[0] == '1':
        p, x = int(req[1]), int(req[2])
        p -= 1
        while p < n and res[p] + x >= a[p]:
            x = res[p] + x - a[p]
            res[p] = a[p]
            indexes[p] = p = find_next(p + 1)
        res[p] += x
    else:
        k = int(req[1])
        stdout.write(f'{res[k - 1]}\n')
