You are given a tree with vertices. Initially, the number written on every vertex is .
For each vertex, you may perform the following operation at most once.
Choose one vertex and change the number written on it to the minimum number written on an adjacent vertex, plus .
If the chosen vertex has no adjacent vertices, the minimum number among adjacent vertices is considered to be .
Find the maximum possible sum of all numbers written on the tree after performing operations in a suitable order.
Input
The input is given in the following format.
The given graph is a tree with vertices. The vertices are numbered from to .
Output
Print the maximum possible sum of all numbers written on the tree.
Constraints
- .
- .
- .
- The given graph is a tree.
Subtasks
Samples
Performing the operation on the only vertex changes its number to .
First perform the operation on vertex , making it . Then perform the operation on vertices and , making both of them . The sum is .
First perform the operation on vertex , making it . Then perform the operation on vertices , making all three of them . The sum is .
해설
관리자가 작성한 해설을 별도 페이지에서 볼 수 있어요.