#D5749. Dungeon 2

    ID: 4776 Type: Default 1000ms 268MiB

Dungeon 2

Dungeon 2

Bob is playing a game called "Dungeon 2" which is the sequel to the popular "Dungeon" released last year. The game is played on a map consisting of NN rooms and N1N-1 roads connecting them. The roads allow bidirectional traffic and the player can start his tour from any room and reach any other room by way of multiple of roads. A point is printed in each of the rooms.

Bob tries to accumulate the highest score by visiting the rooms by cleverly routing his character "Tora-Tora." He can add the point printed in a room to his score only when he reaches the room for the first time. He can also add the points on the starting and ending rooms of Tora-Tora’s journey. The score is reduced by one each time Tora-Tore passes a road. Tora-Tora can start from any room and end his journey in any room.

Given the map information, make a program to work out the maximum possible score Bob can gain.

Input

The input is given in the following format.

NN p1p_1 p2p_2 ...... pNp_N s1s_1 t1t_1 s2s_2 t2t_2 ...... sN1s_{N-1} tN1t_{N-1}

The first line provides the number of rooms NN (1N100,0001 \leq N \leq 100,000). Each of the subsequent NN lines provides the point of the ii-th room pip_i (100pi100-100 \leq p_i \leq 100) in integers. Each of the subsequent lines following these provides the information on the road directly connecting two rooms, where sis_i and tit_i (1si<tiN1 \leq s_i < t_i \leq N) represent the numbers of the two rooms connected by it. Not a single pair of rooms are connected by more than one road.

Output

Output the maximum possible score Bob can gain.

Examples

Input

7 6 1 -1 4 3 3 1 1 2 2 3 3 4 3 5 5 6 5 7

Output

10

Input

4 5 0 1 1 1 2 2 3 2 4

Output

5

inputFormat

Input

The input is given in the following format.

NN p1p_1 p2p_2 ...... pNp_N s1s_1 t1t_1 s2s_2 t2t_2 ...... sN1s_{N-1} tN1t_{N-1}

The first line provides the number of rooms NN (1N100,0001 \leq N \leq 100,000). Each of the subsequent NN lines provides the point of the ii-th room pip_i (100pi100-100 \leq p_i \leq 100) in integers. Each of the subsequent lines following these provides the information on the road directly connecting two rooms, where sis_i and tit_i (1si<tiN1 \leq s_i < t_i \leq N) represent the numbers of the two rooms connected by it. Not a single pair of rooms are connected by more than one road.

outputFormat

Output

Output the maximum possible score Bob can gain.

Examples

Input

7 6 1 -1 4 3 3 1 1 2 2 3 3 4 3 5 5 6 5 7

Output

10

Input

4 5 0 1 1 1 2 2 3 2 4

Output

5

样例

7
6
1
-1
4
3
3
1
1 2
2 3
3 4
3 5
5 6
5 7
10