#include <iostream>
#include <bits/stdc++.h>
using namespace std;
ifstream f ("baruri.in");
ofstream g ("baruri.out");
long long t[400100];
long long v[100005];
void update(int nod, int st, int dr, int poz, int val)
{
if(st==dr)
{
t[nod]=val;
return;
}
int mij = (st+dr)/2;
int x2 = 2*nod;
if(poz<=mij) update(x2,st,mij,poz,val);
else update(x2+1,mij+1,dr,poz,val);
t[nod] = t[x2] + t[x2+1];
}
void update2(int nod, int st, int dr, int poz, int val)
{
if(st==dr)
{
t[nod]+=val;
return;
}
int mij = (st+dr)/2;
int x2 = 2*nod;
if(poz<=mij) update2(x2,st,mij,poz,val);
else update2(x2+1,mij+1,dr,poz,val);
t[nod] = t[x2] + t[x2+1];
}
int getmax(int nod, int st, int dr, int l, int r)
{
if(l<=st && dr<=r) return t[nod];
int ret = 0;
int mij = (st+dr)/2;
int x2 = 2*nod;
if(r>mij) ret = ret + getmax(x2+1,1+mij,dr,l,r);
if(l<=mij) ret = ret + getmax(x2,st,mij,l,r);
return ret;
}
int main()
{
int tt;
int n, m;
f >> tt;
for (int i = 0; i < tt; ++i)
{
f >> n;
for (int j = 0; j < n; ++j)
{
f >> v[j+1];
update(1,1,n,j+1,v[j+1]);
}
f >> m;
for (int j = 0; j < m; ++j)
{
int opt;
f >> opt;
if (opt == 0)
{
int b,d;
f >> b >> d;
g << getmax(1,1,n,max(1,b-d), min(n,b+d)) - v[b] << '\n';
}
else if (opt == 1)
{
int x,b;
f >> x >> b;
update2(1,1,n,b,x);
}
else if (opt == 2)
{
int x, b;
f >> x >> b;
update2(1,1,n,b,-x);
}
else
{
int x, b1, b2;
f >> x >> b1 >> b2;
update2(1,1,n,b1,-x);
update2(1,1,n,b2,x);
}
}
}
return 0;
}