#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, l, r; cin >> n >> l >> r; vector a(n); rep(i, n) cin >> a[i]; int mask[62] = {}; rep(i, n-1) rep(j, 62) { if ((a[i]&1LL<<61-j) == 0 && a[i+1]&1LL<<61-j) { mask[j] |= 1; break; } if (a[i]&1LL<<61-j && (a[i+1]&1LL<<61-j) == 0) { mask[j] |= 2; break; } } rep(i, 62) { if (mask[i] == 3) { cout << 0 << endl; return 0; } } auto DP = [=](ll mx){ ll dp[63][2] = {}; dp[0][0] = 1; rep(i, 62) rep(j, 2) { int n = mx>>61-i&1; if (mask[i] == 0) { for(int k = 0; k <= (j?1:n); k++) dp[i+1][j || (k < n)] += dp[i][j]; } else { int k = (mask[i]==2?1:0); if (j || k<=n) dp[i+1][j || (k < n)] += dp[i][j]; } } return dp[62][1]; }; cout << DP(r+1)-DP(l) << endl; return 0; }