The Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a car in the city u and go by a simple path to city v. He hasn't determined the path, so it's time to do it. Note that chosen path can consist of only one vertex.

A filling station is located in every city. Because of strange law, Nut can buy only w_i liters of gasoline in the i-th city. We can assume, that he has infinite money. Each road has a length, and as soon as Nut drives through this road, the amount of gasoline decreases by length. Of course, Nut can't choose a path, which consists of roads, where he runs out of gasoline. He can buy gasoline in every visited city, even in the first and the last.

He also wants to find the maximum amount of gasoline that he can have at the end of the path. Help him: count it.

Input

The first line contains a single integer n (1 ≤ n ≤ 3 ⋅ 10^5) — the number of cities.

The second line contains n integers w_1, w_2, …, w_n (0 ≤ w_{i} ≤ 10^9) — the maximum amounts of liters of gasoline that Nut can buy in cities.

Each of the next n - 1 lines describes road and contains three integers u, v, c (1 ≤ u, v ≤ n, 1 ≤ c ≤ 10^9, u ≠ v), where u and v — cities that are connected by this road and c — its length.

It is guaranteed that graph of road connectivity is a tree.

Output

Print one number — the maximum amount of gasoline that he can have at the end of the path.

Examples

Input

3
1 3 3
1 2 2
1 3 2


Output

3


Input

5
6 3 2 5 0
1 2 10
2 3 3
2 4 1
1 5 1


Output

7

Note

The optimal way in the first example is 2 → 1 → 3. 

<image>

The optimal way in the second example is 2 → 4. 

<image>
import static java.lang.Math.*;
import static java.util.Arrays.* ;

import java.util.*;
import java.io.*;

public class Main
{
    Edge [][] adjList ;
    int [] label , size ;
    int [] a ;
    TreeSet<Long> cnt;
    int getSize(int u , int p)
    {
        size[u] = 1 ;
        for(Edge e : adjList[u])
            if(label[e.to] == -1 && e.to != p)
                size[u] += getSize(e.to , u) ;
        return size[u] ;
    }
    int getCentroid(int u , int p , int n)
    {
        for(Edge e : adjList[u])
            if(e.to != p && size[e.to] * 2 > n && label[e.to] == -1)
                return getCentroid(e.to , u , n) ;
        return u ;
    }
    void computeDist(int u , int p , long dist , long val)
    {
        cnt.add(val - dist) ;
        for(Edge e : adjList[u])
            if(e.to != p && label[e.to] == -1)
                computeDist(e.to , u , dist + e.cost , val + a[e.to]);

    }
    long decompose(int u  , int lb)
    {
        u = getCentroid(u , -1 , getSize(u , -1)) ;
        long tot = 0 ;
        label[u] = lb ;
        long ans = a[u] ;
        for(Edge e : adjList[u])
            if(label[e.to] == -1)
            {
                cnt = new TreeSet<>() ;
                computeDist(e.to , u , e.cost , a[e.to]);
                ans = max(ans , cnt.last() + tot + a[u]);
                tot = max(tot , cnt.last()) ;
            }

        for(Edge e : adjList[u])
            if(label[e.to] == -1)
                ans = max(ans , decompose(e.to , lb + 1)) ;
        return ans ;
    }
    class Edge{
        int to ;
        long cost ;
        Edge(int a , long b)
        {
            to = a ;
            cost = b ;
        }

    }
    void main() throws Exception
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt() ;
        a = new int [n] ;
        for(int i = 0 ; i < n; i ++)
            a[i] = sc.nextInt() ;
        int [] x = new int [n - 1]  ,y = new int [n - 1]  , z = new int [n - 1], deg = new int [n] ;
        for(int i = 0 ; i < n - 1 ; i++)
        {
            deg[x[i] = sc.nextInt() - 1] ++ ;
            deg[y[i] = sc.nextInt() - 1] ++ ;
            z[i] = sc.nextInt() ;
        }
        adjList = new Edge [n][] ;
        for(int i = 0 ; i < n ; i++)
            adjList[i] = new Edge [deg[i]] ;
        for(int i = 0 ; i < n - 1 ; i++)
        {
            adjList[x[i]][--deg[x[i]]] = new Edge(y[i] , z[i]);
            adjList[y[i]][--deg[y[i]]] = new Edge(x[i] , z[i]) ;
        }
        size = new int [n] ;
        label = new int [n] ;
        fill(label , -1);
        out.println(decompose(0 , 1));
        out.flush();
        out.close();
    }
    class Scanner
    {
        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream in)
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws Exception
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws Exception { return Integer.parseInt(next()); }

        long nextLong() throws Exception { return Long.parseLong(next()); }

        double nextDouble() throws Exception { return Double.parseDouble(next());}
    }

    public static void main (String [] args) throws Exception {(new Main()).main();}

}
