#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=sta;i--) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; typedef complex Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair LP; int n,x[62]; ll L,R,a[200010],dp[62][2][2]; bool l[62],r[62]; ll rec(int k,int flagL,int flagR){ if(k==-1) return 1; if(dp[k][flagL][flagR]!=-1) return dp[k][flagL][flagR]; ll res=0; // 1 if(x[k]!=0 && (flagR || r[k]==1)) res+=rec(k-1,flagL||(l[k]==0),flagR); // 0 if(x[k]!=1 && (flagL || l[k]==0)) res+=rec(k-1,flagL,flagR||(r[k]==1)); dp[k][flagL][flagR]=res; //cout << k << " " << flagL << " " << flagR << " " << res << endl; return res; } void solve(){ cin >> n >> L >> R; rep(k,62){ l[k]=(L & (1ll << k)); r[k]=(R & (1ll << k)); //cout << l[k] << " " << r[k] << endl; rep(flagL,2){ rep(flagR,2){ dp[k][flagL][flagR]=-1; } } } rep(i,n){ cin >> a[i]; } per(k,62){ x[k]=-1; } set se{0,n}; per(k,62){ bool first,changed=false; auto idx=se.begin(); vector v={}; //cout << k << endl; rep(i,n){ bool b=(a[i]&(1ll << k)); //cout << b << " "; if (*idx==i) { first=b; idx++; changed=false; continue; } bool pre_b=(a[i-1]&(1ll << k)); if (pre_b!=b){ v.push_back(i); if(changed) { cout << 0 << endl; return; } else{ changed=true; int s=pre_b; if(x[k]==-1 || x[k]==s){ x[k]=s; } else { cout << 0 << endl; return; } } } } for(int v_:v){ se.insert(v_); //cout << v_ << " "; } //cout << "" << endl; } per(i,62){ //cout << x[i] << " "; } //cout << "" << endl; cout << rec(61,0,0) << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(50); solve(); }