#include using namespace std; typedef pair pii; typedef long long ll; template using V = vector; template using VV = V>; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define ALL(c) (c).begin(),(c).end() #define dump(x) cout << #x << " = " << (x) << endl constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); } template void chmin(T& t, const U& u) { if (t > u) t = u; } template void chmax(T& t, const U& u) { if (t < u) t = u; } template ostream& operator<<(ostream& os, const pair& p) { os<<"("< ostream& operator<<(ostream& os, const vector& v) { os<<"{"; rep(i, v.size()) { if (i) os<<","; os< vec) { if (x == 0) return 0ll; ll res = 0; V fr(sz); for (int i = sz - 1; i >= 0; --i) { for (int j = i-1; j >= 0; --j) { if (vec[j] == -1) { ++fr[i]; } } } bool sm = 1; for (int i = sz - 1; i >= 0; --i) { ll f = (x >> i) & 1; if (sm && vec[i] != -1 && vec[i] > f) { break; } if (sm && f && vec[i] != 1) { res += 1LL << fr[i]; } if (vec[i] != -1 && vec[i] < f) { sm = 0; } } return res; } int main() { int N; ll L, R; cin >> N >> L >> R; V vec(N); rep(i, N) cin >> vec[i]; V col(sz, -1); rep(i, N-1) { for (int j = sz - 1; j >= 0; --j) { if (((vec[i]>>j)&1) != ((vec[i+1]>>j)&1)) { int c = ((vec[i]>>j)&1); if (col[j] == (c ^ 1)) { puts("0"); return 0; } if (c == 0) { col[j] = 0; } else { col[j] = 1; } break; } } } cout << calc(R+1, col) - calc(L, col) << endl; return 0; }