//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} const int N = 2e5+10; //head int n; ll l, r, LR[2]; ll a[N]; int bits[61]; ll ans[2]; ll dp1, dp2; bool dfs(int i, int l, int r) { if(i == -1) return true; int u = -1; int p = a[l]>>i&1LL; for(int j = l; j < r; j++) { if((a[j]>>i&1) == p) { if(u != -1) { return false; } } else u = j; } if(u == -1) { if(bits[i] != 0 and bits[i] != 1) bits[i] = -1; if(!dfs(i-1, l, r)) return false; } else { if(bits[i] == 1 and p == 0) return false; if(bits[i] == 0 and p == 1) return false; bits[i] = p; if(!dfs(i-1, l, u)) return false; if(!dfs(i-1, u, r)) return false; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> l >> r; LR[0] = l-1; LR[1] = r; rep(i, n) cin >> a[i]; fill(bits, bits+61, 100); if(!dfs(60, 0, n)) { cout << 0 << endl; return 0; } rep(u, 2) { if(LR[u] == -1) { ans[u] = 0; continue; } dp1 = dp2 = 0; bool ok = false; for(int i = 60; i >= 0; i--) { if(ok and bits[i] == -1) { dp1 <<= 1; } if(LR[u]>>i&1) { if(!ok) { dp2 = 1; } ok = true; if(bits[i] != 1) dp1 += dp2; } else { if(bits[i] == 1) dp2 = 0; } } ans[u] = dp1+dp2; } cout << ans[1] - ans[0] << endl; }