#include template struct dynamic_segtree { private: struct node; using node_ptr = std::unique_ptr; struct node { int index; S value, product; node_ptr lef, rig; node(int index, S value) : index(index), value(value), product(value), lef(nullptr), rig(nullptr) {} }; const int n; node_ptr root; S value(const node_ptr& t) const { return t == nullptr ? e() : t->product; } node_ptr& set(node_ptr& t, const int a, const int b, int p, S x) const { if(t == nullptr) return t = std::make_unique(p, x); if(t->index == p) { t->value = x; t->product = op(value(t->lef), op(t->value, value(t->rig))); return t; } int c = (a + b) >> 1; if(p < c) { if(t->index < p) std::swap(t->index, p), std::swap(t->value, x); t->lef = std::move(set(t->lef, a, c, p, x)); } else { if(p < t->index) std::swap(p, t->index), std::swap(x, t->value); t->rig = std::move(set(t->rig, c, b, p, x)); } t->product = op(value(t->lef), op(t->value, value(t->rig))); return t; } S get(const node_ptr& t, const int a, const int b, int p) const { if(t == nullptr) return e(); if(t->index == p) return t->value; int c = (a + b) >> 1; if(p < c) return get(t->lef, a, c, p); else return get(t->rig, c, b, p); } S prod(const node_ptr& t, const int a, const int b, int l, int r) const { if(t == nullptr or b <= l or r <= a) return e(); if(l <= a and b <= r) return t->product; int c = (a + b) >> 1; S res = prod(t->lef, a, c, l, r); if(l <= t->index and t->index < r) res = op(res, t->value); return op(res, prod(t->rig, c, b, l, r)); } public: dynamic_segtree(int n) : n(n), root(nullptr) {} void set(int p, S x) { assert(0 <= p and p < n); root = std::move(set(root, 0, n, p, x)); } S get(int p) { assert(0 <= p and p < n); return get(root, 0, n, p); } S prod(int l, int r) { assert(l <= r and r <= n); return prod(root, 0, n, l, r); } }; using S = int; S op(S x, S y) { return x + y; } S e() { return 0; } const int sz = 1e9 + 1; int n, t, x, y; long long res; int main() { dynamic_segtree seg(sz); scanf("%d", &n); while(n--) { scanf("%d%d%d", &t, &x, &y); if(t == 0) seg.set(x, seg.prod(x, x + 1) + y); else res += seg.prod(x, y); } printf("%lld\n", res); return 0; }