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