#define _USE_MATH_DEFINES #include using namespace std; const int N = 62; int mark[N]; long long calc (long long lim, int cur, int f) { if (cur < 0) return 1; long long res = 0; if (mark[cur] == 0) { if (lim & (1LL << cur)) { res += 1LL << (cur - f); } res += calc (lim, cur - 1, f); } if (mark[cur] == 1) { f--; if (lim & (1LL << cur)) { res += 1LL << (cur - f); } else { res += calc (lim, cur - 1, f); } } if (mark[cur] == 2) { f--; if (lim & (1LL << cur)) { res += calc (lim, cur - 1, f); } } return res; } signed main() { ios::sync_with_stdio(false); cin.tie(0); long long n, l, r; cin >> n >> l >> r; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i + 1 < n; i++) { for (int j = N - 1; j >= 0; j--) { if ((a[i] & (1LL << j)) == 0 && (a[i + 1] & (1LL << j))) { mark[j] |= 1; break; } if ((a[i] & (1LL << j)) && ((a[i + 1] & (1LL << j)) == 0)) { mark[j] |= 2; break; } } } int fx = 0; for (int i = 0; i < N; i++) { if (mark[i] == 3) { cout << 0 << '\n'; return 0; } if (mark[i]) fx++; } cout << calc(r, N - 1, fx) - (l ? calc(l - 1, N - 1, fx) : 0) << '\n'; return 0; }