#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 template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int inf = 1 << 28; //constexpr long long mod = 1000000007LL; constexpr long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; ll N, L, R; vector a; vector> can; ll solve(ll x) { vector> dp(63, vector(2)); dp[62][1] = 1; for (int bit = 61; bit >= 0; bit--) { int t = (x >> bit) & 1; if (t == 1) { dp[bit][1] += dp[bit + 1][1] * can[bit][1]; dp[bit][0] += dp[bit + 1][1] * can[bit][0]; } else { dp[bit][1] += dp[bit + 1][1] * can[bit][0]; } dp[bit][0] += dp[bit + 1][0] * (can[bit][0] + can[bit][1]); } return dp[0][0] + dp[0][1]; } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ scanf("%lld %lld %lld", &N, &L, &R); a.resize(N); for (int i = 0; i < N; i++) scanf("%lld", &a[i]); can = vector>(63, vector(2, 1)); for (int i = 0; i < N - 1; i++) { for (int j = 62; j >= 0; j--) { int s = a[i] >> j & 1; int t = a[i + 1] >> j & 1; if (s == 1 and t == 0) { can[j][0] = 0; break; } if (s == 0 and t == 1) { can[j][1] = 0; break; } } } ll res = solve(R); if (L) res -= solve(L - 1); cout << res << endl; return 0; }