#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 100;   vector<int> edge[N];   vector<long long> w[N];   int n, q, top[N], dfn[N], hson[N], siz[N];   int fa[N];   long long val[N], f[N], g[N];   long long a[N], dv[N];   long long dep[N], faw[N];   void dfs(int x) {     f[x] = 0;     siz[x] = 1;     dv[x] = dv[fa[x]] + a[x];     for (int i = 0; i <= (int)edge[x].size() - 1; ++i) {       int y = edge[x][i];       if (y == fa[x]) continue;       fa[y] = x;       dep[y] = dep[x] + w[x][i];       faw[y] = w[x][i];       dfs(y);       siz[x] += siz[y];       if (siz[y] > siz[hson[x]]) hson[x] = y;       f[x] = max(f[x], f[x] + f[y] - w[x][i] * 2 + a[y]);     }     for (int i = 0; i <= (int)edge[x].size() - 1; ++i) {       int y = edge[x][i];       if (y == fa[x]) continue;       if (f[y] - w[x][i] * 2 + a[y] > 0)         val[y] = f[x] - f[y] + w[x][i] * 2 - a[y];       else         val[y] = f[x];     }   }   int tot, an[N];   void dfs2(int x, int k) {     top[x] = k;     dfn[x] = ++tot;     an[tot] = x;     if (!hson[x]) return;     dfs2(hson[x], k);     for (int i = 0; i <= (int)edge[x].size() - 1; ++i) {       int y = edge[x][i];       if (y == fa[x] || y == hson[x]) continue;       dfs2(y, y);     }   }   void dfs3(int x) {     for (int i = 0; i <= (int)edge[x].size() - 1; ++i) {       int y = edge[x][i];       if (y == fa[x]) continue;       g[y] = g[x] + a[x] - 2 * w[x][i];       if (f[y] - w[x][i] * 2 + a[y] < 0)         g[y] += f[x];       else         g[y] += f[x] - f[y] + w[x][i] * 2 - a[y];       if (g[y] < 0) g[y] = 0;       dfs3(y);     }   }   inline int lca(int x, int y) {     while (top[x] != top[y]) {       if (dep[top[x]] < dep[top[y]]) swap(x, y);       x = fa[top[x]];     }     return (dep[x] < dep[y]) ? x : y;   }   long long st[N];   void init() {     st[0] = 0;     for (int i = 1; i <= n; ++i) st[i] = st[i - 1] + val[an[i]];   }   inline long long rmq(int l, int r) { return st[r] - st[l - 1]; }   int son;   long long query(int x, int y) {     long long res = 0;     while (top[x] != top[y]) {       res += rmq(dfn[top[x]], dfn[x]);       if (fa[top[x]] == y) res -= val[top[x]], son = top[x];       x = fa[top[x]];     }     if (!son) son = an[dfn[y] + 1];     if (dfn[y] + 2 <= dfn[x]) res += rmq(dfn[y] + 2, dfn[x]);     return res;   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; ++i) scanf( %lld , a + i);     for (int i = 1; i <= n - 1; ++i) {       int u, v;       long long z;       scanf( %d%d%lld , &u, &v, &z);       edge[u].push_back(v);       edge[v].push_back(u);       w[u].push_back(z);       w[v].push_back(z);     }     fa[1] = dep[1] = 0;     dfs(1);     dfs2(1, 1);     dfs3(1);     init();     for (int i = 1; i <= q; ++i) {       int x, y;       scanf( %d%d , &x, &y);       int w = lca(x, y);       long long res = 0;       son = 0;       if (w == x) {         if (w == y)           res = f[w] + g[w];         else {           res = query(y, w);           res += val[son] + g[w] + f[y];         }       } else if (w == y) {         res = query(x, w);         res += val[son] + g[w] + f[x];       } else {         res = query(x, w) + g[w];         if (f[son] - 2 * faw[son] + a[son] > 0)           res -= f[son] - 2 * faw[son] + a[son];         son = 0;         res += query(y, w);         res += val[son];         res += f[x] + f[y];       }       res += dv[x] + dv[y] - dv[w] - dv[fa[w]] - dep[x] - dep[y] + dep[w] * 2;       printf( %lld n , res);     }     return 0;   }