n, k = map(int, input().split()) A = list(map(int, input().split())) dp = [-1] * (1 << n + 1) dp[0] = k for s in range(1 << n): for i in range(n): ns = s | 1 << i dp[ns] = max(dp[ns], dp[s] % A[i]) # print(s, ns, dp[ns]) print(dp[(1 << n) - 1])