N, K = map(int, input().split()) A = tuple(map(int, input().split())) dp = [0] * (1 << N) dp[0] = K for b in range(1, 1 << N): for i in range(N): if b >> i & 1: dp[b] = max(dp[b - (1 << i)] % A[i], dp[b]) print(dp[-1])