import bisect class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i n = int(input()) qry = [] idx = [] for i in range(n): q = [int(i) for i in input().split()] qry.append(q) if q[0] == 0: idx.append(q[1]) asrt = sorted(set(idx)) adt = { v: i for i, v in enumerate(asrt) } ki = Bit(len(adt)+1) ans = 0 for i in range(n): q,x,y = qry[i] if q == 0: ki.add(adt[x]+1,y) else: l = bisect.bisect_left(asrt,x) r = bisect.bisect_left(asrt,y)+1 ans += ki.sum(r) - ki.sum(l) #print(ans,l,r) print(ans)