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