n=int(input()) l=[] X=[] for i in range(n): a,x,y=map(int,input().split()) l.append((a,x,y)) if a: X.append(x) X.append(y) else: X.append(x) No=2**18 tree=[0]*(2*No) def add(k,x): k+=No-1 while k>=0: tree[k]+=x k=(k-1)//2 def sum(l): L=l+No-1 s=0 while L>0: if L&1: s+=tree[L] L=(L-2)//2 else: L=(L-1)//2 return s ans=0 for i in l: a,x,y=i if a: ans+=sum(y)-sum(x-1) else: add(x,y) print(ans)