#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } ll func(vector& t, ll x){ int msb = -1; for(int k = 60; k >= 0; --k){ if(x >> k & 1){ msb = k; break; } if(t[k] == 2) return 0LL; } vector> dp(msb + 2, vector(2)); dp[msb + 1][0] = 1; for(int i = msb; i >= 0; --i){ if(t[i] == 0){ dp[i][0] += dp[i + 1][0]; dp[i][1] += dp[i + 1][1] * 2; if(x >> i & 1){ dp[i][1] += dp[i + 1][0]; } } else if(t[i] == 1){ dp[i][1] += dp[i + 1][1]; if(x >> i & 1){ dp[i][1] += dp[i + 1][0]; } else{ dp[i][0] += dp[i + 1][0]; } } else{ dp[i][1] += dp[i + 1][1]; if(x >> i & 1){ dp[i][0] += dp[i + 1][0]; } } } return dp[0][0] + dp[0][1]; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; ll L, R; cin >> N >> L >> R; vector A(N); for(int i = 0; i < N; ++i) cin >> A[i]; vector T(61); for(int i = 0; i + 1 < N; ++i){ for(int k = 60; k >= 0; --k){ if((A[i] >> k & 1) == 0 && (A[i + 1] >> k & 1) == 1){ T[k] |= 1; break; } if((A[i] >> k & 1) == 1 && (A[i + 1] >> k & 1) == 0){ T[k] |= 2; break; } } } for(int k = 60; k >= 0; --k){ if(T[k] == 3){ cout << 0 << endl; return 0; } } ll ans = func(T, R); if(L > 0) ans -= func(T, L - 1); cout << ans << endl; return 0; }