#include using namespace std; using ll = long long; using P = pair; int calcBoundary(int bit, int l, int r, vector& a) { ll mask = (1LL << bit); int idx = 0; bool pf = (a[l] & mask); for (int i = l; i < r; i++) { bool f = (a[i] & mask); if (pf != f) { if (idx == 0) { pf = f; idx = i; } else { return -1; } } } return idx; } ll calc_less(int bit, vector& a, vector

& v) { if (bit < 0) return 1; ll res = 1; for (int i = bit; i >= 0; i--) { ll mask = (1LL << i); vector

nv; bool f01 = false, f10 = false; for (P& p : v) { int b = calcBoundary(i, p.first, p.second, a); if (b == -1) return 0; if (b == 0) { nv.push_back(p); } else { nv.emplace_back(p.first, b); nv.emplace_back(b, p.second); if (a[b] & mask) f01 = true; else f10 = true; } } if (f01 && f10) return 0; if (!f10 && !f01) { res <<= 1; } v = move(nv); } cerr << res << ": \n"; return res; } ll solve(ll lim, int n, vector& a) { if (lim < 0) return 0; vector

v; v.emplace_back(0, n); vector dp(2, 0); dp[true] = 1; for (int i = 60; i >= 0; i--) { vector ndp(2, 0); ll mask = (1LL << i); vector

nv; bool f01 = false, f10 = false; for (P& p : v) { int b = calcBoundary(i, p.first, p.second, a); if (b == -1) return 0; if (b == 0) { nv.push_back(p); } else { nv.emplace_back(p.first, b); nv.emplace_back(b, p.second); if (a[b] & mask) f01 = true; else f10 = true; } } if (f01 && f10) return 0; if (!f10) { ndp[false] += dp[false]; if (lim & mask) ndp[false] += dp[true]; else ndp[true] += dp[true]; } if (!f01) { ndp[false] += dp[false]; if (lim & mask) ndp[true] += dp[true]; } dp = move(ndp); v = move(nv); } return dp[false] + dp[true]; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; ll L, R; cin >> n >> L >> R; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; cout << solve(R, n, a) - solve(L - 1, n, a) << "\n"; return 0; }