#include #include #include #define llint long long using namespace std; llint n, l, r; llint a[200005]; bool up[65], down[35]; llint dp[65][2]; bool dfs(llint l, llint r, llint h) { int bd = 0; for(int i = l; i < r; i++){ if(((a[i] >> h) & 1) < ((a[i+1] >> h) & 1)) up[h] = true, bd = i; if(((a[i] >> h) & 1) > ((a[i+1] >> h) & 1)) down[h] = true, bd = i; } if(up[h] && down[h]) return false; if(h > 0){ if(bd) dfs(l, bd, h-1), dfs(bd+1, r, h-1); else dfs(l, r, h-1); } return true; } llint calc(llint x) { if(x < 0) return 0; for(int i = 61; i >= 0; i--){ for(int j = 0; j < 2; j++){ dp[i][j] = 0; } } dp[61][0] = 1; for(int i = 61; i > 0; i--){ for(int j = 0; j < 2; j++){ for(int k = 0; k < 2; k++){ if(up[i-1] && k == 1) continue; if(down[i-1] && k == 0) continue; if(k == 1 && ((x&(1LL<<(i-1))) == 0) && j == 0) continue; int nj = j; if(k == 0 && ((x&(1LL<<(i-1))) != 0)) nj = 1; dp[i-1][nj] += dp[i][j]; } } } /*for(int i = 61; i >= 0; i--){ for(int j = 0; j < 2; j++){ cout << dp[i][j] << " "; } cout << endl; }*/ return dp[0][0] + dp[0][1]; } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> l >> r; for(int i = 1; i <= n; i++) cin >> a[i]; if(!dfs(1, n, 60)){ cout << 0 << endl; return 0; } cout << calc(r) - calc(l-1) << endl; return 0; }