#include"iostream" #include"algorithm" #include"cstring" #include"cstdio" #include"cmath" #include"vector" #include"map" #include"set" #include"queue" usingnamespace std; #define MAXN 126 //#define int long long #define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i) #define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i) #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back #define vi vector<int> #define all(x) (x).begin() , (x).end() #define mem( a ) memset( a , 0 , sizeof a ) typedeflonglong ll; constint P = 1e9 + 7; int n , m; int A[MAXN];
vi val; int dp[MAXN][MAXN][MAXN];
intfuck( int l , int r , int x ){ int& s = dp[l][r][x]; if( ~s ) return s; if( l > r ) return s = 1; if( !x ) return0; s = 0; rep( p , l , r ) s = ( s + fuck( l , p - 1 , min( x , A[p] ) ) * 1ll * fuck( p + 1 , r , min( x , A[p] ) - 1 ) ) % P; return s; }
voidsolve(){ cin >> n; rep( i , 1 , n ) scanf("%d",A + i) , A[i] = min( A[i] , n ); memset( dp , -1 , sizeof dp ); cout << fuck( 1 , n , n ) << endl; }