#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ int N; cin>>N; vector A(N); rep(i,N){ cin>>A[i]; } vector sum(N+1,0); for(int i=N-1;i>=0;i--){ sum[i] = A[i]; sum[i] += sum[i+1]; } vector dp(1024,false); vector moddp(1024,false); moddp[1] = true; dp[1] = true; int ans = 1; rep(i,N){ if(A[i]==0){ for(int j=i;j ndp(1024,false); for(int j=1023;j>=0;j--){ if(j%A[i]!=0)continue; ndp[j] = dp[j/A[i]]; } rep(j,1024){ if(moddp[j]){ int t = j&A[i]; if(!ndp[t]){ ndp[t] = true; ans++; } } } vector nmdp(1024,false); rep(j,1024){ if(ndp[j])nmdp[j] = true; if(moddp[j]){ nmdp[(j*A[i])%1024] = true; } } swap(dp,ndp); swap(moddp,nmdp); cout<