N,K=map(int,input().split()) A=list(map(int,input().split())) MIN=min(A) ANS=K%MIN for a in A: ANS=max(ANS,(K%a)%MIN) import random for i in range(10**6): T=K while T>=MIN: T%=A[random.randint(0,N-1)] ANS=max(ANS,T) print(ANS)