import sys input = sys.stdin.readline n=int(input()) Q=[list(map(int,input().split())) for i in range(n)] LIST=[] for x,a,b in Q: if x==0: LIST.append(a) else: LIST.append(a) LIST.append(b) LIST.sort() N=len(LIST) DICT=dict() for i in range(N): DICT[LIST[i]]=i BIT=[0]*N def update(v,w):#vにwを加える while v0: ANS+=BIT[v] v-=(v&(-v)) return ANS ANS=0 for x,a,b in Q: if x==0: update(DICT[a],b) else: ANS+=getvalue(DICT[b])-getvalue(DICT[a]-1) print(ANS)