In the bead-threading game, thread comes in red and blue. Beads are numbered 1 through n. You start with one bead and may add beads using:
Every thread has a length. When the game ends, the score is the sum of blue thread lengths.
You are given a final connection state: each thread connects two beads with a length, but colors are unknown. Among all ways to produce this state, output the maximum possible final score.
Line 1: n (1≤n≤200000).
Next n−1 lines: ai, bi, ci (1≤ai<bi≤n, 1≤ci≤10000). Beads ai and bi are connected by a thread of length ci.
Print the maximum possible final score.
In the sample, start at bead 3, connect 5, insert 1 between 3 and 5, then append 2 and 4 to 1 for a score of 60. No larger score exists.