You are given a tree with N nodes. Each node i has a value \(A_{i}\) associated with it. You are asked to perform Q queries on it.
Each query contains an integer i.
In each query, you need to remove the \(i^{th}\) edge and find number of connected unordered pair of nodes \(u, v\) such that \(|A_u - A_v| \leq D\).
Note :
The tree is restored to it's original state after each query.
Input :
The first line of the input contains three single space separated integers \(N, D\) and Q.
The next line of the input contains N single space separated integers denoting \(A_i\).
Each of the next \(N - 1\) lines contains two space separated integers u and v , the nodes that the \(i^{th}\) edge connects (Edges are ordered by 1 based index).
Each of the next Q lines of the input contains an integer i corresponding to that query.
Output :
For each query, print the total number of connected unordered pairs \(u, v\) such that \(| A_u - A_v | \leq D\).
Constraints :
- \(2 ≤ N ≤ 10^5\)
- \(1 ≤ A_i ≤ 10^6\)
- \(1 ≤ Q ≤ 10^5\)
- \(0 ≤ D ≤ 20\)