/* -*- coding: utf-8 -*- * * 911.cc: No.911 ラッキーソート - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int BN = 61; /* typedef */ typedef long long ll; /* global variables */ ll as[MAX_N], es[MAX_N], dp[BN + 1]; int ds[BN], bits[BN + 1]; /* subroutines */ ll count(ll a) { ll c = 0; for (int k = BN; k >= 0; k--) { if (((a >> k) & 1) == 0) { if (! (bits[k] & 1)) break; } else { if (bits[k] & 1) c += dp[k]; if (! (bits[k] & 2)) break; } } return c; } /* main */ int main() { int n; ll l, r; scanf("%d%lld%lld", &n, &l, &r); for (int i = 0; i < n; i++) scanf("%lld", as + i); bits[BN] = 3; for (int k = BN - 1; k >= 0; k--) { ll bk = 1LL << k; int ok0 = 1, ok1 = 1; ll pe0 = es[0] | (as[0] & bk), pe1 = pe0 ^ bk; for (int i = 1; i < n; i++) { ll ei0 = es[i] | (as[i] & bk), ei1 = ei0 ^ bk; if (pe0 > ei0) ok0 = 0; if (pe1 > ei1) ok1 = 0; pe0 = ei0, pe1 = ei1; } ds[k] = ok0 + ok1; bits[k] = ok0 | (ok1 << 1); if (ds[k] == 0) { puts("0"); return 0; } ll xk = (ok0) ? 0 : bk; for (int i = 0; i < n; i++) es[i] |= ((as[i] & bk) ^ xk); } dp[0] = 1; for (int k = 0; k < BN; k++) dp[k + 1] = dp[k] * ds[k]; //for (int i = 0; i < BN; i++) putchar('0' + ds[i]); putchar('\n'); ll cl = count(l), cr = count(r + 1); // printf("cl=%lld, cr=%lld\n", cl, cr); printf("%lld\n", cr - cl); return 0; }