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())
arr = [int(i) for i in input().split()]
class Node:
    def __init__(self, i, j):
        self.l = i
        self.r = j
        self.val = 0
        if i + 1 == j:
            self.cap = arr[i]
            return
        mid = (i + j) // 2
        self.left = Node(i, mid)
        self.right = Node(mid, j)
        self.cap = self.left.cap + self.right.cap
        
        
    def get(self, i):
        if self.l + 1 == self.r:
            return self.val
        mid = (self.l + self.r) // 2
        if i >= mid:
            return self.right.get(i)
        else:
            return self.left.get(i)
        
    def update(self, i, val):
        if self.cap - self.val < val:
            val -= self.cap - self.val
            self.val = self.cap
            return val
        elif self.l + 1 == self.r:
            self.val += val
            return 0
        
        mid = (self.l + self.r) // 2
        if i >= mid:
            res = self.right.update(i, val)
        else:
            res = self.left.update(i, val)
            if res > 0:
                res = self.right.insert(res)
        self.val = self.left.val + self.right.val
        return res
                
                
    def insert(self, val):
        if self.cap - self.val < val:
            val -= self.cap - self.val
            self.val = self.cap
            return val
        elif self.l + 1 == self.r:
            self.val += val
            return 0
        else:
            res = self.left.insert(val)
            if res > 0:
                res = self.right.insert(res)
            self.val = self.left.val + self.right.val
            return res
        
node = Node(0, n)
c = int(input())
for _ in range(c):
    k = input().split()
    if k[0] == "1":
        node.update(int(k[1]) - 1, int(k[2]))
    else:
        print(node.get(int(k[1]) - 1))
        
        