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