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*).

class Solution:

    def __init__(self, n, capacities):
        self.w = [0] * (n+1)
        self.parent = list(range(n + 1))
        self.next = list(range(1, n + 2))
        self.capacities = capacities
        pass

    def add_water(self, idx, water):
        while idx < len(self.w):
            remain = self.capacities[idx - 1] - self.w[idx]
            if remain >= water:
                self.w[idx] += water
                return
            else:
                water -= remain
                self.w[idx] += remain
                self.merge(idx - 1, idx)
                idx = self.next[self.find(idx)]
        return

    def query(self, idx):
        return self.w[idx]

    def find(self, x):
        if x == self.parent[x]:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def merge(self, v1, v2):
        r1, r2 = self.find(v1), self.find(v2)
        if r1 == r2:
            return
        self.parent[r2] = r1
        self.next[r1] = self.next[r2]


if __name__ == '__main__':
    # obj = Solution(2, [5, 10])
    # obj.add_water(1, 4)
    # print(obj.query(1))  # 4
    # obj.add_water(2, 5)
    # obj.add_water(1, 4)
    # print(obj.query(1))  # 5
    # print(obj.query(2))  # 8

    # obj = Solution(3, [5, 10, 8])
    # obj.add_water(1, 12)
    # print(obj.query(2))  # 7
    # obj.add_water(1, 6)
    # obj.add_water(3, 2)
    # print(obj.query(2))  # 10
    # print(obj.query(3))  # 5
    n = input()
    capacities = input("")
    obj = Solution(n, capacities)
    q = input()
    for _ in range(q):
        query = input("")
        if query[0] == 1:
            obj.add_water(query[1], query[2])
        else:
            print(obj.query(query[1]))
