#include<bits/stdc++.h>
#define mid ((l + r) >> 1)
#define lchild (root << 1)
#define rchild ((root << 1) + 1)
using namespace std;
const int N = 5e4 + 9,INF = 2e9 + 9;
int n,q;
int a[N];
struct edge{
int to,nex;
} e[N << 1];
int head[N],ecnt;
void addedge(int u,int v){
ecnt++;
e[ecnt] = (edge){v,head[u]};
head[u] = ecnt;
}
int fa[N],dep[N];
int siz[N],w_ch[N];
void dfs1(int u,int father){
fa[u] = father;
siz[u] = 1;
dep[u] = dep[father] + 1;
for(int i = head[u];i;i = e[i].nex){
int v = e[i].to;
if(v != father){
dfs1(v,u);
siz[u] += siz[v];
if(siz[v] > siz[w_ch[u]])
w_ch[u] = v;
}
}
}
int top[N];
int dfn[N],rdfn[N],id;
void dfs2(int u,int link_top){
id++;
dfn[u] = id;
rdfn[id] = u;
top[u] = link_top;
if(w_ch[u]){
dfs2(w_ch[u],link_top);
for(int i = head[u];i;i = e[i].nex){
int v = e[i].to;
if(v != fa[u] && v != w_ch[u])
dfs2(v,v);
}
}
}
vector<pair<int,int> > rec[2];
void split(int u,int v){
rec[0].clear();
rec[1].clear();
int type = 0;
while(top[u] != top[v]) {
if(dep[top[u]] < dep[top[v]]){
swap(u,v);
type ^= 1;
}
rec[type].push_back(make_pair(dfn[top[u]],dfn[u]));
u = fa[top[u]];
}
if(dep[u] > dep[v])
swap(u,v);
else
type ^= 1;
rec[type].push_back(make_pair(dfn[u],dfn[v]));
reverse(rec[1].begin(),rec[1].end());
}
struct node{
int val[2];
int Min,Max;
int tag;
} t[N << 2];
bool in_range(int l,int r,int L,int R){
return L <= l && r <= R;
}
bool out_range(int l,int r,int L,int R){
return l > R || r < L;
}
void push_up(int root){
t[root].val[0] = max(max(t[lchild].val[0],t[rchild].val[0]),t[lchild].Max - t[rchild].Min);
t[root].val[1] = max(max(t[lchild].val[1],t[rchild].val[1]),t[rchild].Max - t[lchild].Min);
t[root].Min = min(t[lchild].Min,t[rchild].Max);
t[root].Max = max(t[lchild].Max,t[rchild].Max);
}
void make_tag(int root,int v){
t[root].tag += v;
t[root].Min += v;
t[root].Max += v;
}
void push_down(int root,int l,int r){
make_tag(lchild,t[root].tag);
make_tag(rchild,t[root].tag);
t[root].tag = 0;
}
void build(int root,int l,int r){
if(l == r){
t[root].Min = t[root].Max = a[rdfn[l]];
return;
}
build(lchild,l,mid);
build(rchild,mid + 1,r);
push_up(root);
}
void update(int root,int l,int r,int L,int R,int v){
if(out_range(l,r,L,R))
return;
if(in_range(l,r,L,R)){
make_tag(root,v);
return;
}
push_down(root,l,r);
update(lchild,l,mid,L,R,v);
update(rchild,mid + 1,r,L,R,v);
push_up(root);
}
int query_min(int root,int l,int r,int L,int R){
if(out_range(l,r,L,R))
return 0;
if(in_range(l,r,L,R))
return t[root].Min;
push_down(root,l,r);
return min(query_min(lchild,l,mid,L,R),query_min(rchild,mid + 1,r,L,R));
}
int query_max(int root,int l,int r,int L,int R){
if(out_range(l,r,L,R))
return 0;
if(in_range(l,r,L,R))
return t[root].Max;
push_down(root,l,r);
return max(query_max(lchild,l,mid,L,R),query_max(rchild,mid + 1,r,L,R));
}
node query_ans(int root,int l,int r,int L,int R,int type){
node ret;
if(out_range(l,r,L,R)){
ret.val[type] = -INF;
ret.Min = INF;
ret.Max = -INF;
return ret;
}
else if(in_range(l,r,L,R)){
ret = t[root];
return ret;
}
push_down(root,l,r);
node lc = query_ans(lchild,l,mid,L,R,type),rc = query_ans(rchild,mid + 1,r,L,R,type);
ret.val[type] = max(max(lc.val[type],rc.val[type]),
(type == 0 ? lc.Max - rc.Min : rc.Max - lc.Min));
ret.Min = min(lc.Min,rc.Min);
ret.Max = max(lc.Max,rc.Max);
return ret;
}
int query(int u,int v){
split(u,v);
int premax = 0,ret = 0;
for(int i = 0;i <= 1;i++){
for(int j = 0;j < rec[i].size();j++){
int l = rec[i][j].first,r = rec[i][j].second;
if(l > r)
swap(l,r);
ret = max(ret,max(premax - query_min(1,1,n,l,r),query_ans(1,1,n,l,r,i).val[i]));
premax = query_max(1,1,n,l,r);
}
}
return ret;
}
void modify(int w){
for(int i = 0;i <= 1;i++){
for(int j = 0;j < rec[i].size();j++){
int l = rec[i][j].first,r = rec[i][j].second;
if(l > r)
swap(l,r);
update(1,1,n,l,r,w);
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n;
for(int i = 1;i <= n;i++)
cin >> a[i];
for(int i = 1;i < n;i++){
int u,v;
cin >> u >> v;
addedge(u,v);
addedge(v,u);
}
dfs1(1,0);
dfs2(1,1);
build(1,1,n);
cin >> q;
while(q--){
int u,v,w;
cin >> u >> v >> w;
cout << query(u,v) << '\n';
modify(w);
}
return 0;
}