//#pragma GCC optimize("Ofast") //#pragma GCC target("avx") //#undef LOCAL #include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template using V = vector; template using VV = V>; #ifdef LOCAL struct PrettyOS { ostream& os; bool first; template auto operator<<(T&& x) { if (!first) os << ", "; first = false; os << x; return *this; } }; template void dbg0(T&&... t) { (PrettyOS{cerr, true} << ... << t); } #define dbg(...) \ do { \ cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \ dbg0(__VA_ARGS__); \ cerr << endl; \ } while (false); #else #define dbg(...) #endif template ostream& operator<<(ostream& os, const pair& p) { return os << "P(" << p.first << ", " << p.second << ")"; } template ostream& operator<<(ostream& os, const V& v) { os << "["; for (auto d : v) os << d << ", "; return os << "]"; } ll up; V fix(62, -1); using S = pair; map dp; ll solve(int he, bool same) { if (he == -1) return 1; auto key = S(he, same); if (dp.count(key)) return dp[key]; ll ans = 0; ll nw = (up >> he) & 1; if (fix[he] != 1) { ans += solve(he - 1, (same) && nw == 0); } if (fix[he] != 0 && !(same && nw == 0)) { ans += solve(he - 1, (same) && nw == 1); } return dp[key] = ans; } ll solve(ll x) { up = x; dp.clear(); return solve(61, true); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int n; ll l, r; cin >> n >> l >> r; V a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { ll x = a[i], y = a[i + 1]; for (int he = 61; he >= 0; he--) { ll u = (x >> he) & 1; ll v = (y >> he) & 1; if (u == v) continue; dbg(x, y, u, v, he); if (u < v) { if (fix[he] == 1) { cout << 0 << endl; return 0; } fix[he] = 0; } else { if (fix[he] == 0) { cout << 0 << endl; return 0; } fix[he] = 1; } break; } } dbg(fix); ll ans = solve(r); if (l) ans -= solve(l - 1); cout << ans << endl; return 0; }