Tracy needs to buy some cake! She finds herself at bakery out of total bakeries. Each bakery has it's own rating, some being so bad the rating is negative. Tracy can travel between two bakeries as long as there is a road connecting the two, and she will always stop at a bakery if she travels to it. It is also guaranteed that Tracy can travel to any bakery from bakery , but she can only visit each bakery once. She can also buy as many cakes as she wants, and she would like the sum of ratings for all bakeries she buys a cake from to be as high as possible. If she stops at a bakery, she must buy a cake there.
Input Specification
The first line will contain one integer , the number of bakeries.
The next line will contain space-separated integers, , representing the rating of the -th bakery.
The following lines will contain two space-separated integers and , indicating that there is an road between bakeries and .
Output Specification
Output a single integer, the maximum possible sum of ratings.
Sample Input 1
3
0 10 15
1 2
1 3
Sample Output 1
15
Sample Input 2
5
1 1 1 -1 1
1 2
1 3
3 4
3 5
Sample Output 2
3
Comments