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

#GL0000345. Đếm dãy con thỏa chia hết theo vị trí (Multiplicity)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đếm dãy con thỏa chia hết theo vị trí (Multiplicity)

Multiplicity

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an array A1,A2,…,ANA_1,A_2,\ldots,A_N. A nonempty subsequence B1,B2,…,BkB_1,B_2,\ldots,B_k is formed by choosing indices 1≤i1<i2<⋯<ik≤N1\le i_1<i_2<\cdots<i_k\le N in their original order, with Bj=AijB_j=A_{i_j}.

The subsequence is good if BjB_j is divisible by its one-based position jj for every 1≤j≤k1\le j\le k.

Count all good subsequences modulo 109+710^9+7. Distinct sets of source indices count as distinct subsequences, even when the selected values are identical.

Input

The first line contains NN, the second line NN integers A1,A2,…,ANA_1,A_2,\ldots,A_N.

Output

Print the number of good subsequences modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤N≤121\le N\le 12, 1≤Ai≤1501\le A_i\le150.
  • Subtask 2 (30 points): 1≤N≤20001\le N\le 2000, 1≤Ai≤1041\le A_i\le 10^4.
  • Subtask 3 (50 points): 1≤N≤1051\le N\le 10^5, 1≤Ai≤1061\le A_i\le 10^6.

Examples

Example 1

Input

2
1 2

Output

3

Explanation

There are exactly three nonempty subsequences: [1], [2], and [1,2]. In the length-two subsequence the second value 2 is divisible by position 2.

Example 2

Input

5
2 2 1 22 14

Output

13

Explanation

There are 5 valid length-one subsequences and 8 valid length-two subsequences; none longer. Thus the answer is 13.