#include using namespace std; int main() { ios::sync_with_stdio(false); int N; int64_t L, R; cin >> N >> L >> R; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } auto calc = [&](int64_t ub, bool inc) -> int64_t { vector must(61, -1); for (int i = 0; i + 1 < N; ++i) { for (int j = 60; ~j; --j) { int x = A[i] >> j & 1; int y = A[i + 1] >> j & 1; if (x == y) continue; if (must[60 - j] == -1) must[60 - j] = y < x; if (must[60 - j] != (y < x)) return 0; break; } } vector> dp(62, vector(2)); dp[0][0] = 1; for (int i = 0; i < 61; ++i) { vector choices; if (must[i] == -1) choices = { 0, 1 }; else choices = { must[i] }; for (int l = 0; l < 2; ++l) { int v = ub >> 60 - i & 1; for (int d : choices) { if (!l && v < d) continue; dp[i + 1][l | d < v] += dp[i][l]; } } } int64_t res = dp[61][1]; if (inc) res += dp[61][0]; return res; }; int64_t ans = calc(R, true) - calc(L, false); cout << ans << endl; return 0; }