def dfs(i, x): res = 0 if i == n: return x for j in range(i + 1, n + 1): tmp = x % a[j] res = max(res, dfs(j, tmp)) return res n, k = map(int, input().split()) a = list(map(int, input().split())) a = [0] + sorted(a, reverse=True) print(dfs(0, k))