#include #define f first #define s second using namespace std; int dp[1205][1205]; int ar[1205]; const int mod=1000000007; int fac[1205],rev[1205],rfac[1205]; inline int P(int a,int b){ return 1ll*fac[a]*rfac[a-b]%mod; } int main(){ fac[0]=1; for(int i=1;i<1201;i++) fac[i]=1ll*i*fac[i-1]%mod; rev[1]=1; for (int i=2;i<1201;i++) rev[i]=1ll*rev[mod%i]*(mod-mod/i)%mod; rfac[0]=1; for (int i=1;i<1201;i++) rfac[i]=1ll*rfac[i-1]*rev[i]%mod; int n; scanf("%d\n",&n); for(int i=0;iar[n-i+k]){ j=i; break; } else now=ar[n-i+k]; } if(j==i)break; if(i-j==1)dp[i][j]=1; else for(int k=0;k