The first line contains an integer \(n(2\leq n\leq 200,000)\) which means the number of nodes.
Then \(n-1\) lines follow. Each line contains two integers \(u,v(1\leq u, v\leq n)\) which means an edge between node \(u\) and node \(v\).
Then one line contains \(n\) integers \(p_i(1\leq p_i \leq 10^8)\).
Print the minimum value of \((e_1+e_2+\cdots +e_n)\) to activate all nodes.
4 1 2 2 3 2 4 2 3 1 1
Explanation for the example: one optimal assignment is \(e_1=3,e_2=0,e_3=3,e_4=1\). Node \(1\) is activated by nodes \(1\) and \(3\). Node \(2\) is activated by nodes \(1\) and \(3\). Node \(3\) is activated by nodes \(3\) and \(4\). Node \(4\) is activated by nodes \(4\) and \(1\).
Tips: You can choose the node with the maximum \(p_i\) value as the root.