#include using namespace std; #include using namespace atcoder; using ll = long long; using vi = vector; using vvi = vector>; using pii = pair; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i) namespace baLoon { struct S { ll val; S() : val(0) {} S(ll val) : val(val){}; S &operator*=(const S &x) { val += x.val; return *this; } S operator*(const S &x) const { S ret = *this; ret *= x; return ret; } }; struct OnlineSegTree { OnlineSegTree(int lowerbound, int upperbound) : lowerbound(lowerbound), upperbound(upperbound), root(nullptr) {} void set(int x, const S &val) { assert(lowerbound <= x && x < upperbound); set(root, lowerbound, upperbound, x, val); } S get(int x) { assert(lowerbound <= x && x < upperbound); return get(root, lowerbound, upperbound, x); } S prod(int l, int r) { assert(lowerbound <= l && l <= r && r <= upperbound); return prod(root, lowerbound, upperbound, l, r); } private: struct node { node(S val) : val(val), left(nullptr), right(nullptr) {} S val; node *left; node *right; }; int lowerbound; int upperbound; node *root; void set(node *&v, int a, int b, const int x, const S &val) { if (!v) v = new node(S()); if (b - a == 1) { v->val = val; } else { int c = (a + b) / 2; if (x < c) { set(v->left, a, c, x, val); } else { set(v->right, c, b, x, val); } v->val = S(); if (v->left) v->val *= v->left->val; if (v->right) v->val *= v->right->val; } } S get(node *&v, int a, int b, int x) { if (!v) return S(); if (b - a > 1) { int c = (a + b) / 2; if (x < c) { return get(v->left, a, c, x); } else { return get(v->right, c, b, x); } } return v->val; } S prod(node *&v, int a, int b, int l, int r) { if (!v || b <= l || r <= a) return S(); if (l <= a && b <= r) return v->val; int c = (a + b) / 2; return prod(v->left, a, c, l, r) * prod(v->right, c, b, l, r); } }; } // namespace baLoon int main() { baLoon::OnlineSegTree seg(0, 1001001001); int n; cin >> n; baLoon::S ret = baLoon::S(); while (n--) { int type; cin >> type; if (type == 0) { int x, y; cin >> x >> y; seg.set(x, seg.get(x) * baLoon::S(y)); } if (type == 1) { int l, r; cin >> l >> r; ret *= seg.prod(l, r + 1); } } cout << ret.val << endl; return 0; }