#include<iostream>
#include<cstdio>
using namespace std;
int T,x,y,i,n,st,dr,c,m,op,C,S,Arb[100005],a[100005];
int Query(int);
void Update(int,int);
int main()
{
freopen("baruri.in","r",stdin);
freopen("baruri.out","w",stdout);
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(i=1; i<=n; ++i)
{
scanf("%d",&x);
Update(i,x);
a[i]=x;
}
scanf("%d",&m);
while(m--)
{
scanf("%d",&op);
if(op == 3)
{
scanf("%d%d%d",&c,&x,&y);
Update(x,-c);a[x]-=c;
Update(y,c);a[y]+=c;
}
else
{
scanf("%d%d",&x,&y);
if(op == 1) Update(y,x), a[y]+=x;
else if(op == 2) Update(y,-x), a[y]-=x;
else
{
st = x-y; dr = x+y;
if(st<1) st=1; if(dr>n) dr=n;
printf("%d\n", Query(dr) - Query(st-1) - a[x]);
}
}
}
for(i=1; i<=n; ++i) a[i]=Arb[i]=0;
}
return 0;
}
void Update(int poz, int val)
{
C = 0;
while ( poz <= n )
{
Arb[poz] += val;
while ( !(poz & (1<<C)) ) C++;
poz += (1<<C);
C += 1;
}
}
int Query(int poz)
{
C = 0, S = 0;
while ( poz > 0 )
{
S += Arb[poz];
while ( !(poz & (1<<C)) ) C++;
poz -= (1<<C);
C += 1;
}
return S;
}