#include using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(LL i = (l) ; i < (r); ++i) #define incII(i, l, r) for(LL i = (l) ; i <= (r); ++i) #define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i) #define decII(i, l, r) for(LL i = (r) ; i >= (l); --i) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() template bool setmin (T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template bool setmax (T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; } LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); } LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); } template T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template T lcm(T a, T b) { return a / gcd(a, b) * b; } #define bit(b, i) (((b) >> (i)) & 1) #define BC __builtin_popcountll #define SC static_cast #define SI(v) SC(v.size()) #define SL(v) SC(v.size()) #define RF(e, v) for(auto & e: v) #define ef else if #define UR assert(false) // ---- ---- const int D = 61; LL n, l, r, a[200000]; bool zero[D], one[D]; LL f(LL v) { pair dp = { 1, 0 }; dec(j, D) { if(zero[j] && one[j]) { return 0; } if(! zero[j] && ! one[j]) { dp.SE *= 2; } if(bit(v, j) == 1 && ! one[j]) { dp.SE += dp.FI; } if(bit(v, j) == 0 && one[j]) { dp.FI = 0; } if(bit(v, j) == 1 && zero[j]) { dp.FI = 0; } } return dp.SE; } int main() { cin >> n >> l >> r; inc(i, n) { cin >> a[i]; } inc(i, n - 1) { dec(j, D) { if(bit(a[i], j) != bit(a[i + 1], j)) { (bit(a[i], j) == 0 ? zero : one)[j] = true; break; } } } cout << f(r + 1) - f(l) << endl; return 0; }