#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(ll i=0;i<(ll)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ ll n;cin>>n; ll b=1<<10; vcdp(b,0),dx(b,0); dp[1]=1; ll over=0; rep(i,n){ ll a;cin>>a; vcpre(b,0),prex(b,0); swap(pre,dp); swap(prex,dx); if(a==0){ dp[0]=1; over=0; continue; } rep(j,b){ ll nj=j&a; if(pre[j]||prex[j])dp[nj]=1; nj=j*a; if(nj>=b){ if(pre[j])over++; if(pre[j]||prex[j])dx[nj&(b-1)]=1; } else{ if(pre[j])dp[nj]=1; if(prex[j])dx[nj]=1; } } ll ans=over; rep(j,b)ans+=dp[j]; cout<