M=10**9+7 m=512 n=read_line.to_i a=read_line.split.map(&.to_i) b=(0...m).map{|i|[0i64]*i} dp=[0i64]*n dp[0]=1 n.times{|i| (1...m).each{|x|dp[i]+=b[x][i% x]%=M} if a[i]1 } p dp[n-1]