1685.Winter is here

Time Limit: 1s Memory Limit: 256MB

Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers.

He has created a method to know how strong his army is. Let the i-th soldier’s strength be ai. For some k he calls i1,i2,...,ik a clan if i1 \lt i2 \lt i3 \lt ... \lt ik and gcd(ai1,ai2,...,aik) \gt 1 . He calls the strength of that clan k \cdot gcd(ai1,ai2,...,aik). Then he defines the strength of his army by the sum of strengths of all possible clans.

Your task is to find the strength of his army. As the number may be very large, you have to print it modulo 1000000007 (109+7).

Greatest common divisor (gcd) of a sequence of integers is the maximum possible integer so that each element of the sequence is divisible by it.

Input Format(From the terminal/stdin)

The first line contains integer n (1 \le n \le 200000)- the size of the army.

The second line contains n integers a1,a2,...,an (1 \le ai \le 1000000)- denoting the strengths of his soldiers.

Output Format(To the terminal/stdout)

Print one integer- the strength of John Snow's army modulo 1000000007 (109+7).

Sample Input 1

Copy
3
3 3 1
 \n
 · · \n

Sample Output 1

Copy
12
  \n

Sample Input 2

Copy
4
2 3 4 6
 \n
 · · · \n

Sample Output 2

Copy
39
  \n

Hints

In the first sample the clans are {1},{2},{1,2} so the answer will be 1 \cdot 3+1 \cdot 3+2 \cdot 3=12

Submit

请先 登录

© 2025 FAQs