#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } templatevoid Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);} const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff; //template end int n; ll a[200010],b[200010][70]={}; ll sum(ll x){ if(x==-1)return 0; ll dp[70][2]={}; //dp[i][j]:=iビットまで j:x以下が確定している dp[63][0]=1; rrep(i,62,-1)rep(j,0,2)if(dp[i+1][j]){ rep(k,0,2){ int nj=j; bool can=1; if(!j&&k&&!(x>>i&1))continue; if((x>>i&1)&&!k)nj=1; rep(l,0,n-1){ if(b[l][i+1]==b[l+1][i+1]){ if(k==0){ if((a[l]>>i&1)>(a[l+1]>>i&1)){ can=0; break; } } else{ if((a[l]>>i&1)<(a[l+1]>>i&1)){ can=0; break; } } } } if(can)dp[i][nj]+=dp[i+1][j]; } } return dp[0][0]+dp[0][1]; } int main(){ ll l,r; scanf("%d%lld%lld",&n,&l,&r); rep(i,0,n){ scanf("%lld",&a[i]); rep(j,0,65)b[i][j]=(a[i]>>j); } bool f=1; rep(i,0,n-1)if(a[i]!=a[i+1])f=0; if(f&&n!=1){ printf("0\n"); return 0; } printf("%lld\n",sum(r)-sum(l-1)); return 0; }