Problem1520--CF839 - D. Winter is here

1520: CF839 - D. Winter is here

[Creator : ]
Time Limit : 2.000 sec  Memory Limit : 256 MiB

Description

Winter is here at the North and the White Walkers are close. John Snow has an army consisting ofnsoldiers. 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 $a_i$. For some $k$ he calls $i_1,i_2,...,i_k$ a clan if $i_1<i_2<i_3<...<i_k$ and $\text{gcd}(a_{i_1},a_{i_2},...,a_{i_k})>1$. He calls the strength of that clan $k·\text{gcd}(a_{i_1},a_{i_2},...,a_{i_k})$. 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 $10^9+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

The first line contains integer $n\ (1≤n≤200,000)$ − the size of the army.
The second line contains $n$ integers $a_1,a_2,...,a_n\ (1≤a_i≤1000,000)$ − denoting the strengths of his soldiers.

Output

Print one integer− the strength of John Snow's army modulo $10^9+7$.

Sample 1 Input

3
3 3 1

Sample 1 Output

12
the clans are {1},{2},{1,2} so the answer will be 1·3+1·3+2·3=12

Sample 2 Input

4
2 3 4 6

Sample 2 Output

39

HINT

CF839D.

EDITORIAL

Source/Category