N,L,R = map(int,input().split()) A = list(map(int,input().split())) C = 61 x = [-1] * C import sys if N == 1: print(R - L + 1) exit() for i in range(N - 1): for j in reversed(range(C)): mask = 1 << j if A[i] & mask == A[i + 1] & mask: continue if A[i] & mask == 0: if x[j] == 1: print(0) exit() x[j] = 0 else: if x[j] == 0: print(0) exit() x[j] = 1 break def calc(S): if S == -1: return 0 dp = [0] * C mask = 1 << (C - 1) if S & mask: if x[-1] == 1: same = 1 dp[-1] = 0 elif x[-1] == 0: same = 0 dp[-1] = 1 else: same = 1 dp[-1] = 1 else: if x[-1] == 1: return 0 elif x[-1] == 0: same = 1 dp[-1] = 0 else: same = 1 dp[-1] = 0 for j in reversed(range(C - 1)): mask = 1 << j if S & mask: if x[j] == 1: dp[j] = dp[j+1] elif x[j] == 0: dp[j] = dp[j+1] + same same = 0 else: dp[j] = dp[j+1] * 2 + same else: if x[j] == 1: dp[j] = dp[j+1] same = 0 elif x[j] == 0: dp[j] = dp[j+1] else: dp[j] = dp[j+1] * 2 return dp[0] + same print(calc(R) - calc(L -1))