#include"bits/stdc++.h" using namespace std; #define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++) #define rep(i,n) REP((i),0,(n)) using ll = long long; template class SegmentTree { private: using F = function; // モノイド型 int n; // 横幅 F f; // モノイド T e; // モノイド単位元 vector data; public: // init忘れに注意 SegmentTree() {} SegmentTree(F f, T e) :f(f), e(e) {} void init(int n_) { n = 1; while (n < n_)n <<= 1; data.assign(n << 1, e); } void build(const vector& v) { int n_ = v.size(); init(n_); rep(i, n_)data[n + i] = v[i]; for (int i = n - 1; i >= 0; i--) { data[i] = f(data[(i << 1) | 0], data[(i << 1) | 1]); } } void set_val(int idx, T val) { idx += n; data[idx] = val; while (idx >>= 1) { data[idx] = f(data[(idx << 1) | 0], data[(idx << 1) | 1]); } } T query(int a, int b) { // [a,b) T vl = e, vr = e; for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if (l & 1)vl = f(vl, data[l++]); // unknown if (r & 1)vr = f(data[--r], vr); // unknown } return f(vl, vr); } }; int main() { // input ll n; cin >> n; vector> querys(n, vector(3)); rep(i, n)rep(j, 3)cin >> querys[i][j]; // compression int cnt = 0; set st; map trans; for (const auto& query : querys) { st.insert(query[1]); if (query[0] == 1)st.insert(query[2]); } for (const auto& num : st)trans[num] = cnt++; // segment init auto f = [](ll a, ll b) {return a + b; }; SegmentTree seg(f, 0); seg.init(cnt); // query ll ans = 0; for (const auto& query : querys) { ll x = query[1], y = query[2]; if (query[0] == 0) { x = trans[x]; ll now = seg.query(x, x + 1); seg.set_val(x, now + y); } else { ll l = trans[x], r = trans[y]; ans += seg.query(l, r + 1); } } cout << ans << endl; return 0; }