CF839D.Winter is here
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 i_{1}<i_{2}<i_{3}<...<i_{k} and gcd(a_{i1},a_{i2},...,a_{ik})>1 . He calls the strength of that clan k⋅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.
输入格式
The first line contains integer n ( 1<=n<=200000 ) — the size of the army.
The second line contains n integers a1,a2,...,an ( 1<=ai<=1000000 ) — denoting the strengths of his soldiers.
输出格式
Print one integer — the strength of John Snow's army modulo 1000000007 ( 109+7 ).
输入输出样例
输入#1
3 3 3 1
输出#1
12
输入#2
4 2 3 4 6
输出#2
39
说明/提示
In the first sample the clans are 1,2,1,2 so the answer will be 1⋅3+1⋅3+2⋅3=12