\(code:\)
void modify(ll l,ll r,ll add)
{
for(int i=l;i<=min(belong[l]*block,r);++i) a[i]+=add,sum[belong[l]]+=add;
if(belong[l]==belong[r]) return;
for(int i=(belong[r]-1)*block+1;i<=r;++i) a[i]+=add,sum[belong[r]]+=add;
for(int i=belong[l]+1;i<=belong[r]-1;++i) tag[i]+=add;
}
ll query(ll l,ll r)
{
ll ans=0;
for(int i=l;i<=min(belong[l]*block,r);++i) ans+=a[i]+tag[belong[l]];
if(belong[l]==belong[r]) return ans;
for(int i=(belong[r]-1)*block+1;i<=r;++i) ans+=a[i]+tag[belong[r]];
for(int i=belong[l]+1;i<=belong[r]-1;++i) ans+=sum[i]+tag[i]*block;
return ans;
}