#include using namespace std; const int N = 1e9 + 100; struct Node { int l, r, a, b, val; Node(int a, int b) : l(-1), r(-1), a(a), b(b), val(0) {} }; vector t = {Node(0, N)}; const int root = 0; int make_node(const int a, const int b) { t.push_back(Node(a, b)); return ssize(t) - 1; } void add(int x, const int p, const int v) { const int a = t[x].a, b = t[x].b; if(b - a == 1) { t[x].val += v; return; } const int c = (a + b) / 2; if(p < c) { if(t[x].l == -1) t[x].l = make_node(a, c); add(t[x].l, p, v); } else { if(t[x].r == -1) t[x].r = make_node(c, b); add(t[x].r, p, v); } t[x].val = 0; if(t[x].l != -1) t[x].val += t[t[x].l].val; if(t[x].r != -1) t[x].val += t[t[x].r].val; } int prod(const int x, const int l, const int r) { const int a = t[x].a, b = t[x].b; if(x == -1 or r <= a or b <= l) return 0; if(l <= a and b <= r) return t[x].val; return prod(t[x].l, l, r) + prod(t[x].r, l, r); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int Q; cin >> Q; int64_t ans = 0; while(Q--) { int cmd; cin >> cmd; if(cmd == 0) { int x, y; cin >> x >> y; add(root, x, y); } if(cmd == 1) { int l, r; cin >> l >> r, ++r; ans += prod(root, l, r); } } cout << ans << "\n"; return 0; }