#include #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() #define pb push_back #define fs first #define sc second #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) using namespace std; template ostream& operator<<(ostream& o,const pair &p){ return o<<"("< ostream& operator<<(ostream& o,const vector &vc){ o<<"{"; for(const T& v:vc) o< using V = vector; template using VV = vector>; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); } #ifdef LOCAL #define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl #else #define show(x) true #endif bool B(ll x,int i){return (x>>i)&1;} int main(){ cin.tie(0); ios::sync_with_stdio(false); //DON'T USE scanf/printf/puts !! cout << fixed << setprecision(20); int N; ll L,R; cin >> N >> L >> R; V A(N); rep(i,N) cin >> A[i]; auto solve = [&](ll X){ // d(62,0); rep(i,N-1){ ll a = A[i], b = A[i+1]; for(int j=61;j>=0;j--) if(B(a^b,j)){ if(B(a,j)) d[j] |= 2; else d[j] |= 1; break; } } rep(i,62) if(d[i] == 3) return 0LL; rep(i,62) d[i]--; show(d); V dp = {1,0}; for(int i=61;i>=0;i--){ V ndp(2); rep(j,2){ rep(x,2){ if(x != d[i] && d[i] != -1) continue; if(j == 0 && x == 1 && !B(X,i)) continue; int nj = j; if(j == 0 && x != B(X,i)) nj = 1; ndp[nj] += dp[j]; } } dp = ndp; } return dp[1]; }; cout << solve(R+1) - solve(L) << endl; }