#P3911. 最小公倍数之和

最小公倍数之和

Description

For A1,A2,,ANA_1, A_2, \cdots, A_N, compute the following value.

i=1Nj=1Nlcm(Ai,Aj)\sum_{i=1}^N\sum_{j=1}^N \mathrm{lcm}(A_i,A_j)

Here, lcm(a,b)\mathrm{lcm}(a, b) denotes the least common multiple of aa and bb.

Input Format

The first line contains an integer NN.

The second line contains NN integers A1,A2,,ANA_1, A_2, \cdots, A_N.

Output Format

Output one integer in a single line, representing the required value.

2
2 3
17

Hint

Constraints:

  • For 30% of the testdata, 1N10001 \le N \le 1000, 1Ai5×1041 \le A_i \le 5 \times 10^4.
  • For another 30% of the testdata, 1N5×1041 \le N \le 5 \times 10^4, 1Ai10001 \le A_i \le 1000.
  • For 100% of the testdata, 1N5×1041 \le N \le 5 \times 10^4, 1Ai5×1041 \le A_i \le 5 \times 10^4.

Translated by ChatGPT 5