using System; class Program { Scanner cin; int N; long L, R; long[] A; int[] ok; long T; long[,] dp; long rec(int idx, int high) { if(idx == -1) { return 1; } if(dp[idx, high] != -1) { return dp[idx, high]; } long ret = 0; for (int i = 0; i <= (high == 1 ? ((T >> idx) & 1) : 1); i++) { if (((ok[idx] >> i) & 1) == 0) { continue; } ret += rec(idx - 1, high & (((T >> idx) & 1) == i ? 1 : 0)); } dp[idx, high] = ret; return ret; } long beet(long S) { if (S < 0) return 0; dp = new long[61, 2]; for (int i = 0; i < 61; i++) { for (int j = 0; j < 2; j++) { dp[i, j] = -1; } } T = S; return rec(60, 1); } void myon() { cin = new Scanner(); N = cin.nextInt(); L = cin.nextLong(); R = cin.nextLong(); A = new long[N]; for(int i = 0; i < N; i++) { A[i] = cin.nextLong(); } ok = new int[61]; long mask = 0, mask2 = 0; for (int i = 60; i >= 0; i--) { mask2 |= 1L << i; for (int j = 0; j < 2; j++) { long next = mask | ((long)j << i); long pre = -1; for (int k = 0; k < N; k++) { long cur = (next ^ A[k]) & mask2; if (cur < pre) { pre = -1; break; } pre = cur; } if (pre != -1) { ok[i] |= 1 << j; } } if (((ok[i] >> 0) & 1) == 0) { mask |= 1L << i; } } Console.WriteLine(beet(R) - beet(L - 1)); } static void Main(string[] args) { new Program().myon(); } } class Scanner { string[] s; int i; readonly char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public string nextLine() { return Console.ReadLine(); } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } }