#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; ll N, L, R; ll a[200500]; ll dfs(ll X) { ll dp[63][2]; for (ll i = 0; i < 63; i++) for (ll j = 0; j < 2; j++) dp[i][j] = 0; dp[62][1] = 1; vector used(N, false); for (ll i = 61; i >= 0; i--) { ll tmp = -1; for (ll j = 0; j < N - 1; j++) { if (used[j]) continue; ll lf = (a[j] >> i & 1); ll rg = (a[j + 1] >> i & 1); if (lf == rg) continue; if (lf == 1) { if (tmp == -1) tmp = 1; else if (tmp == 0) { return 0; } } else { if (tmp == -1) tmp = 0; else if (tmp == 1) { return 0; } } used[j] = true; } if (tmp == -1) { dp[i][1] += dp[i + 1][1]; if(X >> i & 1) dp[i][0] += dp[i + 1][1]; dp[i][0] += dp[i + 1][0] * 2; } else if (tmp == 1) { if (X >> i & 1) { dp[i][1] += dp[i + 1][1]; } dp[i][0] += dp[i + 1][0]; } else { //cout << i << endl; if (!(X >> i & 1)) { dp[i][1] += dp[i + 1][1]; } else { dp[i][0] += dp[i + 1][1]; } dp[i][0] += dp[i + 1][0]; } } return dp[0][0] + dp[0][1]; } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ scanf("%lld %lld %lld", &N, &L, &R); for (ll i = 0; i < N; i++) scanf("%lld", &a[i]); ll res = dfs(R); //cout << res << endl; if (L) res -= dfs(L - 1); cout << res << endl; return 0; }