PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000231. Sức mạnh của các nhóm chiến binh (Winter is here)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Sức mạnh của các nhóm chiến binh (Winter is here)

Sức mạnh của các nhóm chiến binh (Winter is here)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

For each nonempty subsequence of the given array whose GCD exceeds 11, assign the score (subsequence length) times (its GCD). Return the sum of these scores modulo 109+710^9+7. Positions are distinct.

Input

  • First line: integer nn.
  • Second line: nn array elements.

Output

Print the weighted sum modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤n≤20, 1≤ai≤1001\le n\le 20,\ 1\le a_i\le 100.
  • Subtask 2 (30 points): 1≤n≤3000, 1≤ai≤2⋅1041\le n\le 3000,\ 1\le a_i\le 2\cdot10^4.
  • Subtask 3 (50 points): 1≤n≤2⋅105, 1≤ai≤1061\le n\le2\cdot10^5,\ 1\le a_i\le10^6.

Examples

Example 1

Input

3
3 3 1

Output

12

Explanation

The only qualifying groups are the two singletons with value 3 and their two-element group; their weighted sum is 3+3+6=123+3+6=12.

Example 2

Input

4
2 3 4 6

Output

39

Explanation

Summing the weights of all subsequences with GCD greater than one gives 39.