def main1(n,a): dp=[0]*n mod=10**9+7 dp[0]=1 base=0 c=int(n**0.5)+1 c=51 ary=[[0]*(c+1) for _ in range(c+1)] for i in range(n): # マスiに到達するケースを加算 for j in range(1,min(i,c)+1): dp[i]+=ary[j][i%j] dp[i]%=mod dp[i]+=base dp[i]%=mod if i==n-1:break k=a[i] if k==1: base+=dp[i] base%=mod elif k