For a tree with n vertices, color vertex i with color Ai. Define f(x,y) as the number of distinct colors on the simple path from x to y. For each vertex i from 1 to n, calculate ∑nj=1f(i,j).
### Input
- The first line contains an integer n.
- The second line contains n integers Ai.
- The next n−1 lines each contain two integers u,v indicating an edge between vertices u and v.
### Output
- Output n integers, where the i-th integer is ∑nj=1f(i,j).
### Constraints
- 1≤n,Ai≤105.
### Example
Input:
51232312232415
Output:
10911912