#include using namespace std; template struct SegmentTree { using F = function; private : const T id; const F f; long long n; vector node; public : SegmentTree (const F &f, const T id) : f(f), id(id) { } void init (long long sz) { n = 1; while (n < sz) n <<= 1; node.resize(2*n, id); } void build (vector v) { init((long long)v.size()); for (long long i = 0; i < (long long)v.size(); i++) node[i+n] = v[i]; for (long long i = n-1; i > 0; i--) node[i] = f(node[i<<1|0], node[i<<1|1]); } void update (long long 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 (long long l, long long 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[] (long long i) const { return node[i+n]; } }; signed main() { long long n; cin >> n; vector p; vector>> data; for (long long i = 0; i < n; i++) { long long 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(300300); long long ans = 0; for (const auto &e : data) { long long op = e.first; if (op == 0) { long long x; long long y; tie(x, y) = e.second; x = mp[x]; seg.update(x, seg[x] + y); } else { long long l, r; tie(l, r) = e.second; l = mp[l]; r = mp[r]; ans += seg.query(l, r+1); } } cout << ans << endl; return 0; }