#P17327. [ICPC 2018 Nanjing R] Prime Game

[ICPC 2018 Nanjing R] Prime Game

Problem Description

Given a sequence of nn integers aia_i.

Let mul(l,r)=∏i=lrai\text{mul}(l, r) = \prod_{i = l}^{r} a_i and fac(l,r)\text{fac}(l, r) be the number of distinct prime factors of mul(l,r)\text{mul}(l, r).

Please calculate ∑i=1n∑j=infac(i,j)\sum_{i = 1}^{n}\sum_{j = i}^{n}\text{fac}(i, j)

Input Format

The first line contains one integer nn (1≤n≤1061 \le n \le 10^6) —\text{---} the length of the sequence.

The second line contains nn integers aia_i (1≤i≤n,1≤ai≤1061 \le i \le n, 1 \le a_i \le 10^6) —\text{---} the sequence.

Output Format

Print the answer to the equation.

10
99 62 10 47 53 9 83 33 15 24
248
10
6 7 5 5 4 9 9 1 8 12
134