#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node{
int x,y;
};
stack<node> s;
signed main(){
int n;
cin>>n;
while(n--){
int a,b,c;
cin>>a;
if(a==1){
cin>>b>>c;
s.push({b,c});
}else{
int ans=0;
cin>>b;
while(!s.empty()){
node tmp=s.top();
s.pop();
int tmpx=tmp.x,tmpy=tmp.y;
if(tmpy-tmpx+1>b){
ans+=(tmpy-b+1+tmpy)*b/2;
s.push({tmpx,tmpy-b});
break;
}else{
ans+=(tmpx+tmpy)*(tmpx-tmpy+1)/2;
b-=tmpy-tmpx+1;
}
}
cout<<ans<<'\n';
}
}
return 0;
}