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) - 2; if (rn < 2) { rn = 2; } 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]; if (a[i] == 1) { dp[1][i + 2] += dp[0][i]; } else if (a[i] < rn) { int c = i + a[i]; if (c < n) { dp[a[i]][c] += dp[0][i]; } } else { for (int j = i + a[i]; j < n; j += a[i]) { dp[0][j] += dp[0][i]; } } } System.out.println(dp[0][n - 1]); } }