# coding: utf-8 # Your code here! n=int(input()) q=[] toad={} adset=set() for i in range(n): q.append(list(map(int,input().split()))) adset.add(q[i][1]) if q[i][0]: adset.add(q[i][2]) adset=list(adset) adset.sort() for i in range(len(adset)): toad[adset[i]]=i l=[0 for i in range(len(adset))] c=0 for i in q: if i[0]==0: l[toad[i[1]]]+=i[2] else: for j in range(toad[i[1]],toad[i[2]]+1): c+=l[j] print(c)