import sys input = sys.stdin.readline N, K = map(int, input().split()) a = list(map(int, input().split())) a.sort() mn = a[0] a = a[1: ] res = 0 for i in range(1 << (N - 1)): t = K + 0 for j in range(N - 1): if i & (1 << j): t %= a[j] res = max(res, t % mn) print(res)