#include #include using namespace atcoder; using namespace std; using mint = modint; using ll = long long; int X = 500; int main() { mint::set_mod((ll)1e9 + 7); int N;cin >> N; vector A(N + 1, 0); for (int i = 1;i <= N;i++) cin >> A[i]; vector dp(N + 1, 0);dp[N] = 1; vector> sdp(X + 1, vector(X, 0)); for (int i = 1;i <= X;i++) sdp[i][N % i] += 1; for (int i = N - 1;i >= 1;i--) { if (A[i] > X) { int now = A[i] + i; while (now <= N) dp[i] += dp[now],now += A[i]; dp[i] += dp[i + 1]; } else { if (A[i] == 1) { dp[i] += sdp[1][0]; } else { dp[i] = dp[i + 1] + sdp[A[i]][i % A[i]]; } } for (int j = 1;j <= X;j++) sdp[j][i % j] += dp[i]; } cout << dp[1].val() << endl; }