1876: 树上开花(tree)-2024-初中组

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Input

从文件 tree.in 中读入数据。
第一行一个整数 n。
第二行 n 个整数 ai
第三到 n + 1 行,每行两个整数,表示树上的边。

Output

输出到文件 tree.out 中。
一行一个整数表示答案。

Sample Input Copy

5
2 3 2 5 4
1 2
1 3
2 4
2 5

Sample Output Copy

11

HINT