Merchant

No attempts yetTime limit1sMemory limit128 MB

Problem

The cities of Byteland are joined by roads so that between any two cities there is exactly one route, whether direct or passing through other cities. In other words, the road network forms a tree.

A merchant comes to Byteland to make money. He first settles in one city (the starting city) and then travels to another city of his choice (the ending city). Byteland's law forbids him from entering the same city twice along the way, so his route is the unique simple path between the two cities.

Each road has a known value: travelling it, the merchant gains that many bytalars, and a negative value means a loss. His total profit is the sum of the values of all roads on his route. Choose the starting and ending city so that this total profit is as large as possible. The two cities may be the same, in which case the merchant travels no road and his profit is 0.

Input

The first line contains one integer nn (2n1062 \le n \le 10^6), the number of cities, numbered from 11 to nn.

Each of the next n1n - 1 lines contains three integers aa, bb and xx (109x109-10^9 \le x \le 10^9), meaning there is a direct road between cities aa and bb on which the merchant gains xx bytalars (a negative xx is a loss).

Output

Print a single integer: the largest total profit the merchant can earn.