#P12221. Sum of Divisible Pairs in Arithmetic Sequences
Sum of Divisible Pairs in Arithmetic Sequences
Sum of Divisible Pairs in Arithmetic Sequences
Given a positive integer n and a sequence of n positive integers \(a_1, a_2, \ldots, a_n\), for each integer \(d\) from 1 to \(n\), construct an arithmetic sequence \(\{b_i\}\) of length \(n\) with first term and common difference equal to \(d\). That is, the \(i\)-th term is given by:
\[ b_i = i \times d, \quad 1 \le i \le n. \]
Define \(S_d\) as follows:
\[ S_d = \sum_{i=1}^{n} \mathbf{1}_{\{a_i \mid b_i\}}, \] where \(\mathbf{1}_{\{a_i \mid b_i\}}\) equals 1 if \(a_i\) divides \(b_i\) (i.e. \(a_i\) is a divisor of \(b_i\)), or 0 otherwise.
Your task is to compute:
\[ \sum_{d=1}^{n} S_d. \]
inputFormat
The first line contains a single integer \(n\) \((1 \le n \le 1000)\) representing the number of elements in the sequence.
The second line contains \(n\) space-separated positive integers \(a_1, a_2, \ldots, a_n\).
outputFormat
Output a single integer, the value of \(\sum_{d=1}^{n} S_d\).
sample
3
1 1 1
9