#include<bits/stdc++.h>
using namespace std;
const int N=1e5,M=2,INF=0x3f3f3f3f;
int n,q,m;
int a[N];
int to[N<<1],nex[N<<1],h[N],tot=0;
#define v to[i]
#define mid ((l+r)>>1)
#define mi ((ls[x]+rs[x])>>1)
inline void add(int x,int y){
to[++tot]=y,nex[tot]=h[x],h[x]=tot;
}
struct Matrix{
int g[2][2];
inline void init(){memset(g,0,sizeof(g));}
inline Matrix operator * (const Matrix &T) const {
Matrix res;res.init();
for(int i=0;i<M;i++)
for(int j=0;j<M;j++)
for(int k=0;k<M;k++)
res.g[i][j]=max(res.g[i][j],g[i][k]+T.g[k][j]);
return res;
}
}t[N<<2],g[N];
int fa[N],hs[N],sz[N],f[N][2];
void dfs1(int x,int d){
fa[x]=d,sz[x]=1;
f[x][1]=a[x];
for(int i=h[x];i;i=nex[i]){
if(v==d) continue;
dfs1(v,x);
sz[x]+=sz[v];
if(sz[hs[x]]<sz[v]) hs[x]=v;
f[x][1]+=f[v][0];
f[x][0]+=max(f[v][0],f[v][1]);
}
}
int top[N],dfn[N],End[N],cnt=0,id[N];
void dfs2(int x,int y){
top[x]=y,dfn[++cnt]=x,id[x]=cnt,End[y]=cnt;
g[x].g[1][0]=a[x],g[x].g[1][1]=-INF;
if(!hs[x]) return ;
dfs2(hs[x],y);
for(int i=h[x];i;i=nex[i]){
if(v==fa[x]||v==hs[x]) continue;
dfs2(v,v);
g[x].g[0][0]+=max(f[v][0],f[v][1]);
g[x].g[1][0]+=f[v][0];
}
g[x].g[0][1]=g[x].g[0][0];
}
int lc[N<<2],rc[N<<2],ls[N<<2],rs[N<<2],root[N];
inline void pushup(int x){
t[x]=t[lc[x]]*t[rc[x]];
}
int tmp=0;
void build(int &x,int l,int r){
ls[x]=l,rs[x]=r;
x=++tmp;
if(l==r) return t[x]=g[dfn[l]],void();
build(lc[x],l,mid),build(rc[x],mid+1,r);
pushup(x);
}
Matrix las,now;
int pos;
void update(int x){
if(ls[x]==rs[x]) return t[x]=g[dfn[x]],void();
if(pos<=mi) update(lc[x]);
else update(rc[x]);
pushup(x);
}
inline void change(int x,int val){
g[x].g[1][0]+=val-a[x];a[x]=val;
while(x){
las=t[root[id[x]]];cout<<'@'<<x<<'\n';
pos=id[x],update(root[top[x]]);
now=t[root[top[x]]];
x=fa[top[x]];
g[x].g[0][0]+=max(now.g[0][0],now.g[1][0])-max(las.g[0][0],las.g[1][0]);
g[x].g[0][1]=g[x].g[0][0];
g[x].g[1][0]+=now.g[0][0]-las.g[0][0];
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int x,y,last=0;
cin>>n>>q;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<n;i++){
cin>>x>>y;
add(x,y),add(y,x);
}
dfs1(1,0);dfs2(1,1);
for(int i=1;i<=n;i++) if(top[i]==i) build(root[i],id[i],End[i]);
for(int i=1;i<=q;i++){
cin>>x>>y;
change(x,y);
cout<<(max(g[root[1]].g[0][0],g[root[1]].g[1][0]))<<'\n';
}
return 0;
}