跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F0656. Winter is here

    ID: 662 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>组合数学动态规划数学数论提高难度共享题库Codeforces英文题面题目来源题面语言

Winter is here

题目描述

D. Winter is here
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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<i2<i3<...<ik and gcd(ai1,ai2,...,aik)>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.

Input

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.

Output

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

Examples
Input
3
3 3 1
Output
12
Input
4
2 3 4 6
Output
39
Note

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


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 70 题。保留原作者与原赛事署名。