#include using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const unsigned int M=1000000007; struct modint{ unsigned int v=0; modint(unsigned int a=0){ v=a; } void operator+=(modint r){ v+=r.v; if(v>=M) v-=M; } }; const int sqZ=256; int N; int A[100000]; modint dp[100001]; modint C[sqZ+1][sqZ]; int main(){ scanf("%d",&N); rep(i,N) scanf("%d",&A[i]); dp[0]=1; int m[sqZ+1]={}; rep(i,N){ for(int d=1; d<=sqZ; d++) dp[i]+=C[d][m[d]]; if(i==N-1) break; if(A[i]==1){ C[1][0]+=dp[i]; } else if(A[i]<=sqZ){ dp[i+1]+=dp[i]; C[A[i]][m[A[i]]]+=dp[i]; } else{ dp[i+1]+=dp[i]; for(int j=i+A[i]; j