from bisect import bisect_left as bl N = 18 X = [0] * (2**(N+1)-1) def add(j, x): i = 2**N + j - 1 while i >= 0: X[i] += x i = (i-1) // 2 def rangeof(i): s = (len(bin(i+1))-3) l = ((i+1) - (1<= b or r <= a: return 0 if a <= l and r <= b: return X[i] return rangesum(a, b, 2*i+1) + rangesum(a, b, 2*i+2) Q = int(input()) s = 0 Y = [] Z = set([]) for _ in range(Q): t, a, b = map(int, input().split()) Y.append((t, a, b)) if t == 1: Z |= set([a, b]) Z = list(Z) for t, a, b in Y: if t == 0: add(bl(Z, a), b) else: s += rangesum(bl(Z, a), bl(Z, b)+1) print(s)