Split The Tree

You are given a tree with n vertices, numbered from 1 to n. i-th vertex has a value $w_i$.
We define the weight of a tree as the number of different vertex value in the tree.
If we delete one edge in the tree, the tree will split into two trees. The score is the sum of these two tree weights.
We want to know the maximal score we can get if we delete the edge optimally.

Input
Input is given frome Standard Input in the following format:
$n$
$p_2$ $p_3$ … $p_n$
$w_1$ $w_2$ … $w_n$
Constraints
$2\leq n \leq 100000$ ,$1\leq p_i < i$ , $1 \leq w_i 100000(1\leq i\leq n)$ , and they are integers.
$p_i$ means there is a edge between $p_i$ and i.

Output
Print one number denotes the maximal score.

Sample Input

3
1 1
1 2 2
3
1 1
1 1 1

Sample Output

3
2

-------------本文结束感谢您的阅读-------------