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 java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class B {

    String fileName = "";
    //////////////////////    SOLUTION   SOLUTION  SOLUTION    //////////////////////////////
    long INF = Long.MAX_VALUE / 1000;
    long MODULO = 1000 * 1000 * 1000 + 9;
    int[][] steps = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
    private final static Random rnd = new Random();
    double eps = 1e-1;

    class Pair implements Comparable<Pair>{
        int val, ind;

        public Pair(int val, int ind) {
            this.val = val;
            this.ind = ind;
        }

        @Override
        public int compareTo(Pair o) {
            return -Integer.compare(this.val, o.val);
        }
    }
    ArrayList<Edge>[] graph;
    long[] w;
    boolean[] used;
    long ans = 0;
    void solve() throws IOException {
        int n = readInt();
        graph = new ArrayList[n];
        for (int i=0; i<n; ++i) graph[i] = new ArrayList<>();
        w = new long[n];
        used = new boolean[n];
        for (int i=0; i<n; ++i) {
            w[i] = readLong();
            ans = Math.max(ans, w[i]);
        }

        for (int i=0; i<n-1; ++i){
            int from = readInt() - 1;
            int to = readInt() - 1;
            int dist = readInt();
            graph[from].add(new Edge(to, dist));
            graph[to].add(new Edge(from, dist));
        }
        dfs(0, 0);
        out.println(ans);
    }
    long dfs(int from, int eDist){
        used[from] = true;
        long max1 = 0;
        long max2 = 0;
        for (Edge e: graph[from]){
            if (!used[e.to]){
                max2 = Math.max(max2, dfs(e.to, e.dist));
                if (max1 < max2){
                    long t = max1;
                    max1 = max2;
                    max2 = t;
                }
            }
        }
        ans = Math.max(ans, w[from] + max1 + max2);
        return w[from] + max1 - eDist;
    }


    class SegmentTree{
        long[] t;
        int n;
        SegmentTree(long[] arr, int n){
            t = new long[n*4];
            build(arr, 1, 1, n);
        }
        void build(long[] arr, int v, int tl , int tr){
            if (tl == tr) {
                t[v] = arr[tl];
                return;
            }
            int tm = (tl + tr) / 2;
            build(arr, 2 * v, tl, tm);
            build(arr, 2 * v + 1, tm + 1, tr);
            t[v] = Math.max(t[2*v], t[2*v + 1]);
        }

        long get(int v, int tl , int tr, int l , int r){
            if (l > r) return -1;
            if (tl == l && tr == r) return t[v];
            int tm = (tl + tr) / 2;
            long val1 = get(2 * v, tl, tm, l, Math.min(tm, r));
            long val2 = get(2 * v + 1, tm + 1, tr, Math.max(tm + 1, l), r);
            return Math.max(val1, val2);
        }

    }
    void brute(){
        int n = 10;
        int[] arr = new int[n];
        int[] b = new int[n];
        for (int it=0; it < 100; ++it){
            for (int i=0; i< n; ++i) {
                arr[i] = rnd.nextInt(100);
                b[i] = arr[i];
            }
            Arrays.sort(b);
            for (int k=0; k<n; ++k){
                int ans = orderStatistic(arr, k, 0, n-1);
                if (ans != b[k]) {
                    out.println("HACK!!!");
                    out.println(n +" " + (k+1));
                    for (int i: arr) out.print(i +" ");
                    out.println();
                    out.println(b[k] + " " + ans);
                }
            }
        }
    }
    int orderStatistic(int[] arr, int k, int l , int r){
        int part = partition(arr, l , r);
        if (part == k) return arr[part];
        if (part > k) return orderStatistic(arr, k, l, part);
        return orderStatistic(arr, k, part, r);
    }

    int partition(int[] arr, int l, int r){
        int i = l;
        int j = r;
        if (i == j) return i;
        int pivot = arr[l + rnd.nextInt(r - l)];
        while (true){
            while (arr[i] < pivot) i++;
            while (arr[j] > pivot) j--;
            if (j <= i) return j;
            int temp = arr[j];
            arr[j] = arr[i];
            arr[i] = temp;
            j--; i++;
        }
    }
    long binPow(long a, long b, long m) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return ((a % m) * (binPow(a, b - 1, m) % m)) % m;
        } else {
            long c = binPow(a, b / 2, m);
            return (c * c) % m;
        }

    }

    class Fenwik {
        int[] t;
        int n;
        Fenwik(int n){
            t = new int[n];
            this.n = n;
        }

        void inc(int r, int delta){
            for (; r < n; r = r | (r + 1)) t[r] += delta;
        }
        int getSum(int r){
            int res = 0;
            for (; r >=0; r = (r & (r + 1) ) - 1) res += t[r];
            return res;
        }
    }
    boolean isPrime(int n){
        for (int i=2; i*i<=n; ++i){
            if (n%i==0) return false;
        }
        return true;
    }



    class Number implements Comparable<Number>{
        int x, cost;
        Number(int x, int cost){
            this.x = x;
            this.cost = cost;
        }

        @Override
        public int compareTo(Number o) {
            return Integer.compare(this.cost, o.cost);
        }
    }



    ///////////////////////////////////////////////////////////////////////////////////////////


    class SparseTable{
        int[][] rmq;
        int[] logTable;
        int n;
        SparseTable(int[] a){
            n = a.length;
            logTable = new int[n+1];
            for(int i = 2; i <= n; ++i){
                logTable[i] = logTable[i >> 1] + 1;
            }
            rmq = new int[logTable[n] + 1][n];
            for(int i=0; i<n; ++i){
                rmq[0][i] = a[i];
            }

            for(int k=1; (1 << k) < n; ++k){
                for(int i=0; i + (1 << k) <= n; ++i){
                    int max1 = rmq[k - 1][i];
                    int max2 = rmq[k-1][i + (1 << (k-1))];
                    rmq[k][i] = Math.max(max1, max2);
                }
            }
        }

        int max(int l, int r){
            int k = logTable[r - l];
            int max1 = rmq[k][l];
            int max2 = rmq[k][r - (1 << k) + 1];
            return Math.max(max1, max2);
        }
    }
    long checkBit(long mask, int bit){
        return (mask >> bit) & 1;
    }

    static int checkBit(int mask, int bit) {
        return (mask >> bit) & 1;
    }
    boolean isLower(char c){
        return c >= 'a' && c <= 'z';
    }
    class Edge{
        int to, dist;

        public Edge(int to, int dist) {
            this.to = to;
            this.dist = dist;
        }
    }
    class Vertex implements Comparable<Vertex>{
        int from, count;

        public Vertex(int from, int count) {
            this.from = from;
            this.count = count;
        }

        @Override
        public int compareTo(Vertex o) {
            return Long.compare(this.count, o.count);
        }
    }

    ////////////////////////////////////////////////////////////



    int gcd(int a, int b){
        return b == 0 ? a : gcd(b, a%b);
    }
    long gcd(long a, long b){
        return b == 0 ? a : gcd(b, a%b);
    }
    double binPow(double a, int pow){
        if (pow == 0) return 1;
        if (pow % 2 == 1) {
            return a * binPow(a, pow - 1);
        } else {
            double c = binPow(a, pow / 2);
            return c * c;
        }
    }

    int minInt(int... values) {
        int min = Integer.MAX_VALUE;
        for (int value : values) min = Math.min(min, value);
        return min;
    }

    int maxInt(int... values) {
        int max = Integer.MIN_VALUE;
        for (int value : values) max = Math.max(max, value);
        return max;
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        new B().run();
    }

    void run() throws NumberFormatException, IOException {
        solve();
        out.close();
    };

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok;
    String delim = " ";

    B() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }

        }
        tok = new StringTokenizer("");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) {
                return null;
            }

            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }
    byte readByte() throws NumberFormatException, IOException {
        return Byte.parseByte(readString());
    }
    int[] readIntArray (int n) throws NumberFormatException, IOException {
        int[] a = new int[n];
        for(int i=0; i<n; ++i){
            a[i] = readInt();
        }
        return a;
    }
    int[] readIntArrayWithDecrease (int n) throws NumberFormatException, IOException {
        int[] a = new int[n];
        for(int i=0; i<n; ++i){
            a[i] = readInt() - 1;
        }
        return a;
    }
    Integer[] readIntegerArray (int n) throws NumberFormatException, IOException {
        Integer[] a = new Integer[n];
        for(int i=0; i<n; ++i){
            a[i] = readInt();
        }
        return a;
    }

    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(readString());
    }
}