lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end struct Mint @@MOD = 1_000_000_007i64 def self.mod @@MOD end def self.zero Mint.new(0) end def initialize(n) @n = n.to_i64 % @@MOD end getter n : Int64 def + : self self end def - : self Mint.new(n != 0 ? @@MOD - @n : 0) end def +(m) Mint.new(@n + m.to_i64 % @@MOD) end def -(m) Mint.new(@n - m.to_i64 % @@MOD) end def *(m) Mint.new(@n * m.to_i64 % @@MOD) end def /(m) raise DivisionByZeroError.new if m == 0 a, b, u, v = m.to_i64, @@MOD, 1i64, 0i64 while b != 0 t = a // b a -= t * b a, b = b, a u -= t * v u, v = v, u end Mint.new(@n * u) end def //(m) self / m end def **(m : Int) t, res = self, Mint.new(1) while m > 0 res *= t if m.odd? t *= t m >>= 1 end res end def ==(m) @n == m.to_i64 end def !=(m) @n != m.to_i64 end def succ self + 1 end def pred self - 1 end def to_i64 : Int64 @n end delegate to_s, to: @n delegate inspect, to: @n end struct Int def to_mint : Mint Mint.new(self) end end class String def to_mint : Mint Mint.new(self) end end n = read_line.to_i a = read_line.split.map(&.to_i) sqrt_n = Math.sqrt(n).to_i plus = Array.new(sqrt_n) { |i| [Mint.zero] * i } dp = [Mint.zero] * n dp[0] = Mint.new(1) (0...n).each do |i| (1...sqrt_n).each do |x| dp[i] += plus[x][i % x] end if a[i] < sqrt_n plus[a[i]][i % a[i]] += dp[i] else (i + a[i]...n).step(a[i]) { |j| dp[j] += dp[i] } end if i + 1 < n && a[i] > 1 dp[i + 1] += dp[i] end end puts dp[n - 1]