Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

F. The Chocolate Spree

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputAlice and Bob have a tree (undirected acyclic connected graph). There are *a*_{i} chocolates waiting to be picked up in the *i*-th vertex of the tree. First, they choose two different vertices as their starting positions (Alice chooses first) and take all the chocolates contained in them.

Then, they alternate their moves, selecting one vertex at a time and collecting all chocolates from this node. To make things more interesting, they decided that one can select a vertex only if he/she selected a vertex adjacent to that one at his/her previous turn and this vertex has not been already chosen by any of them during other move.

If at any moment one of them is not able to select the node that satisfy all the rules, he/she will skip his turns and let the other person pick chocolates as long as he/she can. This goes on until both of them cannot pick chocolates any further.

Due to their greed for chocolates, they want to collect as many chocolates as possible. However, as they are friends they only care about the total number of chocolates they obtain together. What is the maximum total number of chocolates they may pick?

Input

The first line of the input contains the single integer *n* (2 ≤ n ≤ 100 000) — the number of vertices in the tree.

The second line contains *n* integers *a*_{i} (1 ≤ *a*_{i} ≤ 10^{9}), *i*-th of these numbers stands for the number of chocolates stored at the node *i*.

Then follow *n* - 1 lines that describe the tree. Each of them contains two integers *u*_{i} and *v*_{i} (1 ≤ *u*_{i}, *v*_{i} ≤ *n*) — indices of vertices connected by the *i*-th edge.

Output

Print the number of chocolates Alice and Bob can collect together if they behave optimally.

Examples

Input

9

1 2 3 4 5 6 7 8 9

1 2

1 3

1 4

1 5

1 6

1 7

1 8

1 9

Output

25

Input

2

20 10

1 2

Output

30

Note

In the first sample, Alice may start at the vertex 9 and Bob at vertex 8. Alice will select vertex 1 and Bob has no options now. Alice selects the vertex 7 and they both stop.

In the second sample, both of them will pick either of the nodes alternately.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/20/2019 20:01:56 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|