You are given a tree T with N nodes and the tree is rooted at node 1. Each node has a value A[i] associated with it. Let us define a set X as follows:
X={v1,v2,....,vk} , set X has nodes v1,v2,.....,vk such that there does not exist an edge between any two vertices in X.
Also, F(v) is the maximum value node present in the subtree of node v (including itself).
V(X) = ∑i=ki=1F(vi) where {v1,v2,....,vk} belong to X
Find the maximum value of V(X).
Input format
Output format
For each test case, print the maximum value of F(X) in a new line.
Constraints
1≤T≤101≤N≤1051≤A[i]≤106
F[1] = 100, F[2] = 99, F[3] = 2 .
Now if X = {2,3} , as there does not exist an edge between node 2 and 3.
Then V(X) = F[2] + F[3] = 99 + 2 = 101.