#include using namespace std; template struct Segtree_ptr{ int N; typedef function Func; Func f; T e; struct Node{ int l, r; Node* ch[2]; T val; Node(int l, int r, T val):l(l), r(r), val(val){ ch[0] = ch[1] = nullptr; } }; Node* root; Segtree_ptr(){} Segtree_ptr(int Nin, Func fin, T ein){ initialize(Nin, fin, ein); } void initialize(int Nin, Func fin, T ein){ f = fin; e = ein; N = 1; while(N < Nin) N <<= 1; root = new Node(0, N, e); } T getval(Node* node){ return (node ? node->val : e); } void recalculate(Node* node){ node->val = f(getval(node->ch[0]), getval(node->ch[1])); } void update(int k, T x){ update(root, k, x); } void update(Node* node, int k, T x){ int l = node->l, r = node->r; if(k < l || r <= k) return; if(r-l == 1){ node->val += x; }else{ int d = (r-l)/2; int t = (k-l)/d; if(!node->ch[t]) node->ch[t] = new Node(l + t*d, l + (t+1)*d, e); update(node->ch[t], k, x); recalculate(node); } } // [a, b] inclusive T between(int a, int b){ return query(root, a, b+1); } T query(Node* node, int a, int b){ if(!node) return e; int l = node->l, r = node->r; if(b <= l || r <= a) return e; if(a <= l && r <= b) return node->val; return f(query(node->ch[0], a, b), query(node->ch[1], a, b)); } }; int main(){ int N; cin >> N; int MX = 1e9+2; Segtree_ptr st(MX, [](int64_t a, int64_t b){ return a+b; }, 0); int64_t ans = 0; while(N--){ int q, x, y; scanf("%d %d %d", &q, &x, &y); if(q == 0){ st.update(x, y); }else{ ans += st.between(x, y); } } cout << ans << endl; return 0; }