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) print(ANS)