import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } br.close(); int mod = 1000000007; int rn = (int) Math.sqrt(n); long[][] dp = new long[rn][n + 2]; dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 1; j < rn; j++) { int p = i - j; if (p < 0) { break; } dp[j][i] += dp[j][p]; dp[j][i] %= mod; } for (int j = 1; j < rn; j++) { dp[0][i] += dp[j][i]; } dp[0][i] %= mod; dp[0][i + 1] += dp[0][i]; dp[0][i + 1] %= mod; if (a[i] == 1) { dp[1][i + 2] += dp[0][i]; dp[1][i + 2] %= mod; } else if (a[i] < rn) { int c = i + a[i]; if (c < n) { dp[a[i]][c] += dp[0][i]; dp[a[i]][c] %= mod; } } else { for (int j = i + a[i]; j < n; j += a[i]) { dp[0][j] += dp[0][i]; dp[0][j] %= mod; } } } System.out.println(dp[0][n - 1]); } }