In ICPCCamp, there are n cities and (n - 1) (bidirectional) roads between cities.
The i-th road is between the

-th and

-th cities.
It is guaranteed that cities are connected.
In the i-th city, there is a defense tower with power

.
The tower protects all cities with a road directly connected to city i.
However, the tower in city i does not protect city i itself.
Bobo would like to destroy all defense towers.
When he tries to destroy the tower in city i, any not-destroyed tower protecting city i will deal damage whose value equals to its power to Bobo.
Find out the minimum total damage Bobo will receive if he chooses the order to destroy the towers optimally.