/*** author: yuji9511 ***/ #include using namespace std; typedef long long ll; typedef pair lpair; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);i>=(n);i--) #define printa(x,n) for(ll i=0;i void print(H&& h, T&&... t){cout<(t)...);} int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N,L,R; cin >> N >> L >> R; ll A[200010]; rep(i,0,N) cin >> A[i]; // rep(i,0,N){ // cout << bitset<16>(A[i]) << endl; // } ll pos = -1; rrep(bit,61,0){ ll cnt = 0; rep(i,0,N){ if((A[i]>>bit) & 1) cnt++; } if(cnt != N && cnt != 0){ pos = bit; break; } } ll diff = (1LL<<(pos+1)); ll ans = 0; rep(bit,0,(1LL<<(pos+1))){ vector b(N); rep(i,0,N){ b[i] = (A[i]^bit); } bool ok = true; rep(i,0,N-1){ if(b[i] >= b[i+1]) ok = false; } if(ok){ ll lv = L - bit; if(lv < 0){ lv = 0; }else{ lv = (lv + diff-1) / diff; } ll rv = R - bit; if(rv < 0){ print(0); return 0; }else{ rv /= diff; } ans += rv-lv+1; } } print(ans); // print(pos); // rep(i,L,R+1){ // vector b(N); // rep(j,0,N){ // b[j] = (A[j]^i); // } // bool ok = true; // rep(j,0,N-1){ // if(b[j] >= b[j+1]) ok = false; // } // if(ok){ // print(i); // printa(b, N); // } // } }