n,k = map(int,input().split()) a = list(map(int,input().split())) a.sort() nax = 0 from collections import deque import bisect for i in range(n): u = a[:i] crt = k % a[i] # print(a[i], crt) for j in range(n): if crt < a[j]: u = a[:j] break # print(u) q = deque([]) q.append((crt, u)) while q: now = q.popleft() if not now[1]: nax = max(nax, now[0]) else: for j in range(len(now[1])): crt = now[0] % now[1][j] t = bisect.bisect_right(now[1], crt) q.append((crt, now[1][:t])) # print(q) # print(nax) print(nax)