#include #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) #define rep2(i, l, r) for (int i = (l); i < (r); i++) #define repr2(i, l, r) for (int i = (r) - 1; i >= (l); i--) #define range(a) a.begin(), a.end() using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); ll N, L, R; cin >> N >> L >> R; vector A(N); rep(i, N) cin >> A[i]; ll dp[62][2][2] = {}; dp[61][0][0] = 1; repr(i, 61) { bool can[2] = {}; auto sorted = [&]() { rep(j, N-1) { if ((A[j] >> i) > (A[j + 1] >> i)) return false; } return true; }; if (sorted()) { can[0] = true; } rep(j, N) A[j] ^= 1LL << i; if (sorted()) { can[1] = true; } else { rep(j, N) A[j] ^= 1LL << i; } rep(j, 2) rep(k, 2) { int x = L >> i & 1; int y = R >> i & 1; int l = j ? 0 : x; int r = k ? 1 : y; rep2(d, l, r + 1) if (can[d]) { dp[i][j || d > x][k || d < y] += dp[i + 1][j][k]; } } } ll ans = 0; rep(j, 2) rep(k, 2) ans += dp[0][j][k]; cout << ans << endl; }