import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 from functools import lru_cache n, l, r = LI() aa = LI() # for a in aa: print(bin(a)[2:].zfill(12)) bb = [-1]*65 def chk(k, l, r): if k < 0: return True m = -1 pb = aa[l] >> k & 1 for i, a in enumerate(aa[l+1:r], l+1): b = a >> k & 1 if b != pb: if m == -1: m = i else: return False pb = b if m == -1: if chk(k-1, l, r) == False: return False else: if bb[k] == -1: bb[k] = 1-pb elif bb[k] != 1-pb: return False if chk(k-1, l, m) == False: return False if chk(k-1, m, r) == False: return False return True if chk(65, 0, n) == False: print(0) exit() # kケタ見終わって、その桁以降が以下でもよい(1)か、未満でなければいけない(0)か @lru_cache(None) def solve(k, f): if k == 65: return f res = 0 if f: if lim[k]: if bb[k] != 1: res += solve(k+1, 1) if bb[k] != 0: res += solve(k+1, 1) else: if bb[k] != 1: res += solve(k+1, 1) if bb[k] != 0: res += solve(k+1, 0) else: if lim[k]: if bb[k] != 1: res += solve(k+1, 1) if bb[k] != 0: res += solve(k+1, 0) else: if bb[k] != 1: res += solve(k+1, 0) if bb[k] != 0: res += solve(k+1, 0) return res lim = [r >> k & 1 for k in range(65)] # print(lim) R = solve(0, 1) solve.cache_clear() L=0 if l>0: lim = [(l-1) >> k & 1 for k in range(65)] L = solve(0, 1) # print(R, L) print(R-L)