N, K = map(int, input().split())
X = sorted(list(map(int, input().split())))[::-1]
R = 0
for i in range(2**N):
    c = 0
    t = K
    cs = []
    while i:
        i, m = divmod(i, 2)
        if m:
            t = t%X[c]
            cs.append(c)
        c += 1
    R = max(R, t%X[-1])
#    print(cs, t)
print(R)