#include <bits/stdc++.h>
using namespace std;
#define sc(p) scanf("%d",&p)
#define pr(p) printf("%d",p)
const int N=100100;
const int oo=0x7FFFFFFF;
int bit1[N],bit2[N];
void add (int x,int d) { for (int i=x; i<=N; i+=i&-i) bit1[i]+=d,bit2[i]+=x*d; }
int sum (int x) { int sb=0; for (int i=x; i; i-=i&-i) sb+=(x+1)*bit1[i]-bit2[i]; return sb; }
int main()
{
int n; sc(n);
for (int i=1; i<=n; i++)
{
int s,a,b,c;
cin>>s>>a>>b;
if (s==1) sc(c),add (a,c),add (b+1,-c);
else cout<<sum (b)-sum(a-1)<<endl;
}
return 0;
}