import math import sys from operator import itemgetter input = sys.stdin.readline # a = int(input().rstrip()) # a, b = map(int, input().rstrip().split()) # D = list(map(int, input().rstrip().split())) # H = [int(input().rstrip()) for _ in range(L)] # DD = [[0 for j in range(100)] for i in range(200)] # dict = {} ## dictionary # if __name__ == '__main__': N = int(input().rstrip()) dict = {} ## dictionary ans = 0 for i in range(N): a, b, c = map(int, input().rstrip().split()) if (a == 0): if (dict.get(b)): dict[b] += c else: dict[b] = c else: for j in dict: if (b <= j <= c): ans += dict[j] print(ans)