Classical Hard GCD Problem

Time limit: 3s Memory limit: 1024MB Input: Output:

Mr. COACH\mathbb{Mr. \ COACH} likes teaching his students about divisors. He came up with the following problem:

You are given an array AA of length nn. We define f(i,j)=gcd(ai,ai+1,aj)max(ai,ai+1,aj)f(i,j) = gcd(a_i, a_{i+1}, \ldots a_j) \cdot max(a_i, a_{i+1}, \ldots a_j).

Determine i=1nj=inf(i,j)\sum_{i=1}^{n} \sum_{j=i}^{n}f(i,j) modulo 109+710^9 + 7

Input data

The first line will contain nn (1n21051 \le n \le 2 \cdot 10^5). On the next line there are nn integers a1,a2,ana_1, a_2, \ldots a_n (1ai1091 \le a_i \le 10^9)

Output data

Print the sum modulo 109+710^9 + 7

Example 1

stdin

4
1 2 3 4

stdout

50

Example 2

stdin

5
2 4 6 12 3

stdout

457

Log in or sign up to be able to send submissions!