#pragma GCC target("avx") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("O3") #include using namespace std; const long long MOD = 1000000007; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector dp(N, 0); dp[0] = 1; vector> next(N); for (int i = 0; i < N; i++){ for (auto &&P : next[i]){ P.second %= MOD; dp[i] += P.second; if (i + P.first < N){ next[i + P.first][P.first] += P.second; } } dp[i] %= MOD; if (i < N - 1 && A[i] != 1){ dp[i + 1] += dp[i]; if (dp[i + 1] >= MOD){ dp[i + 1] -= MOD; } } if (i + A[i] < N){ next[i + A[i]][A[i]] += dp[i]; } } cout << dp[N - 1] << "\n"; }