Problem Statement
You are given an undirected tree with $N$ vertices.
Let us call the vertices Vertex $1$, Vertex $2$, $\ldots$, Vertex $N$. For each $1\leq i\leq N-1$, the $i$-th edge connects Vertex $U_i$ and Vertex $V_i$.
Additionally, each vertex is assigned a positive integer: Vertex $i$ is assigned $A_i$.
The cost between two distinct vertices $s$ and $t$, $C(s,t)$, is defined as follows.
Let
$p_1(=s)$,$p_2$,$\ldots$,$p_k(=t)$be the vertices of the simple path connecting Vertex$s$and Vertex$t$, where$k$is the number of vertices in the path (including the endpoints). Then, let$C(s,t)=k\times \gcd (A_{p_1},A_{p_2},\ldots,A_{p_k})$, where$\gcd (X_1,X_2,\ldots, X_k)$denotes the greatest common divisor of$X_1,X_2,\ldots, X_k$.
Find $\displaystyle\sum_{i=1}^{N-1}\sum_{j=i+1}^N C(i,j)$, modulo $998244353$.
Constraints
$2 \leq N \leq 10^5$$1 \leq A_i\leq 10^5$$1\leq U_i<V_i\leq N$- All values in input are integers.
- The given graph is a tree.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \cdots A_N
U_1 V_1
U_2 V_2
\vdots
U_{N-1} V_{N-1}
Output
Print $\displaystyle\sum_{i=1}^{N-1}\sum_{j=i+1}^N C(i,j)$, modulo $998244353$.
样例
4
24 30 28 7
1 2
1 3
3 4
47
10
180 168 120 144 192 200 198 160 156 150
1 2
2 3
2 4
2 5
5 6
4 7
7 8
7 9
9 10
1184
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。