#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; template vector make_v(U size, const T& init){ return vector(static_cast(size), init); } template auto make_v(U size, Ts... rest) { return vector(static_cast(size), make_v(rest...)); } template void chmin(T &a, const T &b){ a = (a < b ? a : b); } template void chmax(T &a, const T &b){ a = (a > b ? a : b); } int main() { ll n, l, r; cin >> n >> l >> r; vector v(n); for (auto &&i : v) scanf("%lld", &i); vector c(63, -1); for (int i = 0; i+1 < n; ++i) { for (int j = 62; j >= 0; --j) { if((v[i] & (1LL << j)) != (v[i+1] & (1LL << j))){ ll cc = (v[i] & (1LL << j) ? 1 : 0); if(c[j] == -1) c[j] = cc; else if(c[j] != cc){ puts("0"); return 0; } break; } } } ll ans = 0; auto dp = make_v(64, 2, 0LL); dp[63][0] = 1; for (int i = 62; i >= 0; --i) { ll p = (1LL & (r >> i)); if(c[i] == -1){ for (int j = 0; j < 2; ++j) { ll d = (j ? 1 : p); for (int k = 0; k <= d; ++k) { dp[i][j | (k < d)] += dp[i+1][j]; } } }else { for (int j = 0; j < 2; ++j) { ll d = (j ? 1 : p); for (int k = c[i]; k <= d && k < c[i]+1; ++k) { dp[i][j | (k < d)] += dp[i+1][j]; } } } } ans += dp[0][0] + dp[0][1]; if(l != 0){ dp = make_v(64, 2, 0LL); dp[63][0] = 1; for (int i = 62; i >= 0; --i) { ll p = (1LL & ((l-1) >> i)); if(c[i] == -1){ for (int j = 0; j < 2; ++j) { ll d = (j ? 1 : p); for (int k = 0; k <= d; ++k) { dp[i][j | (k < d)] += dp[i+1][j]; } } }else { for (int j = 0; j < 2; ++j) { ll d = (j ? 1 : p); for (int k = c[i]; k <= d && k < c[i]+1; ++k) { dp[i][j | (k < d)] += dp[i+1][j]; } } } } ans -= dp[0][0] + dp[0][1]; } cout << ans << "\n"; return 0; }