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*).
import sys
input = sys.stdin.readline

def solve():
    n = int(input())
    maxns = list(map(int, input().split())) # 最多能装的水
    water = [0] * n # 目前已经装的水
    m = int(input())

    # ---------------------------------------------
    # DSU
    parent = list(range(n))

    def find(index: int) -> int:
        if parent[index] != index:
            parent[index] = find(parent[index])
        return parent[index]

    def union(index1: int, index2: int):
        # 后者作为爸爸
        parent[find(index1)] = find(index2)

    # ---------------------------------------------

    for _ in range(m):
        # DSU
        # 满了的话，指向下一个，下一个为father
        # 如果father不是自己，那么自己必定是满的
        # 如果father是自己，看自己的值
        lst = list(map(int, input().split()))
        if lst[0] == 1:
            p, x = lst[1] - 1, lst[2]
            # 往p序号增加x单位水
            while True:
                #print(x)
                p = parent[p]
                # 这个fa能装完
                if x <= maxns[p] - water[p]:
                    water[p] += x
                    break

                x -= maxns[p] - water[p] # 先减x
                water[p] = maxns[p] # 再装满
                # 流下去
                p = p + 1
                if p == n:
                    break
                # 并起来，下面的作为爸爸
                union(p - 1, p)
            #print(water)

        else:
            k = lst[1] - 1
            print(water[k])



if __name__ == '__main__':
    solve()