import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) M = int(N**0.5) dp = [0]*N dp[0] = 1 acc = [[0]*M for _ in range(M)] MOD = 10**9+7 for i in range(N): if i>0 and A[i-1]>1: dp[i] += dp[i-1] dp[i] %= MOD for j in range(1, M): dp[i] += acc[j][(i+1)%j] dp[i] %= MOD if A[i]>=M: for j in range(i+A[i], N, A[i]): dp[j] += dp[i] dp[j] %= MOD else: acc[A[i]][(i+1)%A[i]] += dp[i] acc[A[i]][(i+1)%A[i]] %= MOD print(dp[N-1])