The input consists of a single test case.
The first line contains one integer n, the number of nodes. (1≤n≤200,000)
The second line contains n space separated integers p, the penalty of each node in order of node number. (1≤p≤1,000,000)
Each of the next n−1 lines contains three space separated integers i, j and w, describing an edge between node i and node j with weight w. (1≤i≤n, 1≤j≤n, i=j, 1≤w≤1,000,000)