N,K,*A=map(int,open(0).read().split()) A.sort(reverse=True) def f(k,i): if i==N: return k return max(f(k%A[j],j+1) for j in range(i,N)) print(f(K,0))