#include using namespace std; #define endl '\n' #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define spa << " " << #define test cout<<"test"<= (ll)(n); i--) using ll = long long; using ld = long double; const ll MOD = 1e9+7; //const ll MOD = 998244353; const ll INF = 1e18; using P = pair; template void chmin(T &a,T b){if(a>b)a=b;} template void chmax(T &a,T b){if(a void ans(bool x,T1 y,T2 z){if(x)cout< void debug(vector>&v,ll h,ll w){for(ll i=0;i&v,ll h,ll w){for(ll i=0;i void debug(vector&v,ll n){if(n!=0)cout< vector>vec(ll x, ll y, T w){ vector>v(x,vector(y,w));return v;} ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;} vectordx={1,0,-1,0,1,1,-1,-1}; vectordy={0,1,0,-1,1,-1,1,-1}; template vector make_v(size_t a,T b){return vector(a,b);} template auto make_v(size_t a,Ts... ts){ return vector(a,make_v(ts...)); } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); //cout<>n>>l>>r; vectora(n); rep(i,0,n)cin>>a[i]; vectort(61,-1); rep(i,0,n-1){ bitset<62>x=a[i]; bitset<62>y=a[i+1]; rrep(i,0,62){ if(x[i]!=y[i]){ if(x[i]){ if(t[i]==-1)t[i]=1; else if(t[i]==0)judge=false; } else{ if(t[i]==-1)t[i]=0; else if(t[i]==1)judge=false; } break; } } } if(judge){ reverse(ALL(t)); //debug(t,61); auto dp=make_v(62,2,2,0LL); dp[0][0][0]=1; rep(i,0,61){ ll lp=(1LL<<60-i)&l,rp=(1LL<<60-i)&r; if(lp!=0)lp=1;if(rp!=0)rp=1; //cout<=40)debug(dp[i+1],2,2); } rep(i,0,2)rep(j,0,2)res+=dp[61][i][j]; cout<