#include <cstdio>
#include <cstring>
#include <iostream>
#define lson x<<1
#define rson x<<1|1
using namespace std;
const int maxn=200010;
typedef long long ll;
int n,m,cnt;
int to[maxn<<1],next[maxn<<1],head[maxn],p[maxn],Q[maxn],dep[maxn],fa[maxn],top[maxn],siz[maxn],son[maxn];
char str[5];
ll sv[maxn<<2],ts[maxn<<2],sc[maxn<<2],v[maxn],g[maxn];
inline void add(int a,int b)
{
to[cnt]=b,next[cnt]=head[a],head[a]=cnt++;
}
void dfs1(int x)
{
siz[x]=1;
for(int i=head[x];i!=-1;i=next[i]) if(to[i]!=fa[x])
{
fa[to[i]]=x,dep[to[i]]=dep[x]+1,dfs1(to[i]),siz[x]+=siz[to[i]];
if(siz[to[i]]>siz[son[x]]) son[x]=to[i];
g[x]+=min(g[to[i]],v[to[i]]);
}
if(siz[x]==1) g[x]=1<<30;
}
void dfs2(int x,int tp)
{
p[x]=++p[0],Q[p[0]]=x,top[x]=tp;
if(son[x]) dfs2(son[x],tp);
for(int i=head[x];i!=-1;i=next[i]) if(to[i]!=fa[x]&&to[i]!=son[x]) dfs2(to[i],to[i]);
}
inline void pushdown(int x)
{
if(ts[x]) sc[lson]-=ts[x],sc[rson]-=ts[x],ts[lson]+=ts[x],ts[rson]+=ts[x],ts[x]=0;
}
void build(int l,int r,int x)
{
if(l==r)
{
sv[x]=v[Q[l]],sc[x]=v[Q[l]]-g[Q[l]];
return ;
}
int mid=(l+r)>>1;
build(l,mid,lson),build(mid+1,r,rson);
sv[x]=min(sv[lson],sv[rson]),sc[x]=min(sc[lson],sc[rson]);
}
ll getg(int l,int r,int x,int a)
{
if(l==r) return sv[x]-sc[x];
pushdown(x);
int mid=(l+r)>>1;
if(a<=mid) return getg(l,mid,lson,a);
return getg(mid+1,r,rson,a);
}
ll getv(int l,int r,int x,int a,int b)
{
if(l==r) return sv[x];
pushdown(x);
int mid=(l+r)>>1;
if(b<=mid) return getv(l,mid,lson,a,b);
if(a>mid) return getv(mid+1,r,rson,a,b);
return min(getv(l,mid,lson,a,b),getv(mid+1,r,rson,a,b));
}
ll getc(int l,int r,int x,int a,int b)
{
if(a<=l&&r<=b) return sc[x];
pushdown(x);
int mid=(l+r)>>1;
if(b<=mid) return getc(l,mid,lson,a,b);
if(a>mid) return getc(mid+1,r,rson,a,b);
return min(getc(l,mid,lson,a,b),getc(mid+1,r,rson,a,b));
}
void upg(int l,int r,int x,int a,int b,ll c)
{
if(a<=l&&r<=b)
{
if(c==-1) sc[x]+=v[Q[l]]-sv[x],sv[x]=v[Q[l]];
else sc[x]-=c,ts[x]+=c;
return ;
}
pushdown(x);
int mid=(l+r)>>1;
if(a<=mid) upg(l,mid,lson,a,b,c);
if(b>mid) upg(mid+1,r,rson,a,b,c);
sv[x]=min(sv[lson],sv[rson]),sc[x]=min(sc[lson],sc[rson]);
}
inline void change(int x,ll d)
{
while(x)
{
ll gx=getg(1,n,1,p[x]),fx=min(gx,v[x]);
upg(1,n,1,p[x],p[x],d);
if(gx>=v[x]) return ;
if(gx+d>v[x]) d=v[x]-fx,x=fa[x];
else
{
if(top[x]==x) x=fa[x];
else if(getc(1,n,1,p[top[x]],p[x]-1)>=d)
{
upg(1,n,1,p[top[x]],p[x]-1,d);
x=fa[top[x]];
}
else
{
int l=p[top[x]],r=p[x],mid;
while(l<r)
{
mid=(l+r)>>1;
if(getc(1,n,1,mid,p[x]-1)>=d) r=mid;
else l=mid+1;
}
if(r<p[x]) upg(1,n,1,r,p[x]-1,d);
x=Q[r-1];
}
}
}
}
inline int rd()
{
int ret=0,f=1; char gc=getchar();
while(gc<‘0‘||gc>‘9‘) {if(gc==‘-‘) f=-f; gc=getchar();}
while(gc>=‘0‘&&gc<=‘9‘) ret=ret*10+gc-‘0‘,gc=getchar();
return ret*f;
}
int main()
{
n=rd();
int i,a,b;
for(i=1;i<=n;i++) v[i]=rd();
memset(head,-1,sizeof(head));
for(i=1;i<n;i++) a=rd(),b=rd(),add(a,b),add(b,a);
dep[1]=1,dfs1(1),dfs2(1,1);
m=rd();
build(1,n,1);
for(i=1;i<=m;i++)
{
scanf("%s",str);
if(str[0]==‘C‘)
{
a=rd(),b=rd();
ll gx=getg(1,n,1,p[a]),fx=min(gx,v[a]);
v[a]+=b,upg(1,n,1,p[a],p[a],-1);
if(min(v[a],gx)>fx) change(fa[a],min(v[a],gx)-fx);
}
else a=rd(),printf("%lld\n",min(v[a],getg(1,n,1,p[a])));
}
return 0;
}//4 4 3 2 1 1 2 1 3 4 2 4 Q 1 Q 2 C 4 10 Q 1