#include <bits/stdc++.h>
using namespace std;
int n;
stack<long long> s;
stack<long long> sl;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
while (n--)
{
int op, ans = 0;
cin >> op;
if (op == 1)
{
int l, r;
cin >> l >> r;
sl.push(l);
s.push(r);
}
else if (op == 2)
{
int k, ll, rr;
cin >> k;
ll = sl.top();
rr = s.top();
if (!s.empty() && rr - k + 1 >= ll)
{
int bg = rr - k + 1;
int ed = rr;
ans = (bg + ed) * k / 2;
s.pop();
s.push(bg - 1);
}
else
{
while (!s.empty() && !sl.empty() && rr - k + 1 < ll)
{
ll = sl.top();
rr = s.top();
int t = (rr - ll + 1);
ans += (ll + rr) * t / 2;
k -= (rr - ll + 1);
sl.pop();
s.pop();
}
if (!s.empty())
{
rr = s.top();
int bg = rr - k + 1;
int ed = rr;
ans += (bg + ed) * k / 2;
s.pop();
s.push(bg - 1);
}
}
cout << ans << endl;
}
}
return 0;
}