class BIT(): def __init__(self, n): self.n = n self.data = [0]*(n+1) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): # assert i > 0 while i <= self.n: self.data[i] += x i += i & -i def get(self, i, j): return self.sum(j) - self.sum(i) N = int(input()) lsQ = [] ss = [0] for i in range(N): a,x,y = map(int,input().split()) lsQ.append((a,x,y)) if a == 0: ss.append(x) else: ss.append(x) ss.append(y) dic = {x:i+1 for i,x in enumerate(sorted(set(ss)))} ans = 0 BI = BIT(len(ss)) for a,x,y in lsQ: if a == 0: BI.add(dic[x],y) else: ans += BI.get(dic[x]-1, dic[y]) print(ans)