#include using namespace std; template struct SegmentTree { using F = function; private : const T id; const F f; int n; vector node; public : SegmentTree (const F &f, const T id) : f(f), id(id) { } void init (int sz) { n = 1; while (n < sz) n <<= 1; node.resize(2*n, id); } void build (vector v) { init((int)v.size()); for (int i = 0; i < (int)v.size(); i++) node[i+n] = v[i]; for (int i = n-1; i > 0; i--) node[i] = f(node[i<<1|0], node[i<<1|1]); } void update (int i, const T &x) { i += n; assert(i < node.size()); node[i] = x; while (i > 0) { i >>= 1; node[i] = f(node[i<<1], node[i<<1|1]); } } const T query (int l, int r) const { T vl = id, vr = id; for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l&1) vl = f(vl, node[l++]); if (r&1) vr = f(node[--r], vr); } return f(vl, vr); } const T &operator[] (int i) const { return node[i+n]; } }; int main() { int n; cin >> n; vector p; vector>> data; for (int i = 0; i < n; i++) { int op, x, y; cin >> op >> x >> y; data.emplace_back(op, make_pair(x, y)); if (op == 0) { p.emplace_back(x); } else { p.emplace_back(x); p.emplace_back(y); } } map mp; sort(p.begin(), p.end()); for (const auto &x : p) { mp[x] = (lower_bound(p.begin(), p.end(), x) - p.begin()); } auto f = [](long long a, long long b) -> long long { return a + b; }; SegmentTree seg(f, 0); seg.init(n+1); int ans = 0; for (const auto &e : data) { int op = e.first; if (op == 0) { int x; long long y; tie(x, y) = e.second; x = mp[x]; seg.update(x, seg[x] + y); } else { int l, r; tie(l, r) = e.second; l = mp[l]; r = mp[r]; ans += seg.query(l, r+1); } } cout << ans << endl; return 0; }