#include #include #include using namespace std; typedef long long LL; const int N = 200010, B = 62; int n, tgt[B], d[B]; LL l, r, a[N], f[B], ans; LL DFS(int pos, bool tight) { if (pos == 0) return 1; if (!tight && ~f[pos]) return f[pos]; LL ret = 0LL; for (int i = 0; i <= (tight ? d[pos] : 1); ++i) { if (tgt[pos] == -1 || tgt[pos] == i) { ret += DFS(pos - 1, tight && i == d[pos]); } } // tight = true 的情况不用缓存 if (!tight) f[pos] = ret; return ret; } LL Calc(LL x) { if (x < 0) return 0; for (int i = 1; i <= 61; ++i) d[i] = x >> (i - 1) & 1; memset(f, -1, sizeof(f)); return DFS(61, true); } int main() { scanf("%d%lld%lld", &n, &l, &r); for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]); memset(tgt, -1, sizeof(tgt)); for (int i = 1; i < n; ++i) { for (int j = 61; j >= 1; --j) { if ((a[i] >> (j - 1) & 1) != (a[i + 1] >> (j - 1) & 1)) { int v = a[i] >> (j - 1) & 1; if (tgt[j] != -1 && tgt[j] != v) { printf("0\n"); return 0; } tgt[j] = v; break; } } } ans = Calc(r) - Calc(l - 1); printf("%lld\n", ans); return 0; }