#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define ms(arr,a) memset(arr,a,sizeof arr)
#define debug(x) cout<<"< "#x" = "<<x<<" >"<<endl
const int maxF=1e5+5;
int n,q;
long long s[maxF],ss[maxF];
inline lowbit(int x)
{
return x&(-x);
}
void adds(int i,long long k)
{
while(i<=n)
{
s[i]+=k;
i+=lowbit(i);
}
}
void addss(int i,long long k)
{
while(i<=n)
{
ss[i]+=k;
i+=lowbit(i);
}
}
long long sums(int i)
{
long long ret=0;
while(i)
{
ret+=s[i];
i-=lowbit(i);
}
return ret;
}
long long sumss(int i)
{
long long ret=0;
while(i)
{
ret+=ss[i];
i-=lowbit(i);
}
return ret;
}
int main()
{
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
while(~scanf("%d%d",&n,&q))
{
long long tmp;
for(int i=1;i<=n;++i)
{
scanf("%lld",&tmp);
adds(i,tmp);addss(i,tmp*i);
}
int a,b,c;
for(int i=1;i<=q;++i)
{
scanf("%d%d%d",&a,&b,&c);
if(a==1)
{
printf("%lld
",1LL*(c+1)*(sums(c)-sums(b-1))-sumss(c)+sumss(b-1));
}
else{
long long tmp=sums(b)-sums(b-1);
adds(b,1LL*c-tmp);addss(b,1LL*b*c-tmp*b);
}
}
}
//freopen("CON","w",stdout);
//system("start Output.txt");
}