N,K=map(int,input().split()) ans=0 A=list(map(int,input().split())) #bitdp (2**N N) dp=[0 for i in range(2**N)] #dp["0010101101"] := ex).A_2,,,,,,A_8を並び替えたときの考えうる最もいい最大値 dp[0]=K for i in range(1,2**N): x=format(i,"0%ib"%N)[::-1] for j in range(N): if x[j]=="1": dp[i]=max(dp[i],dp[i-2**j]%A[j]) ans=dp[-1] print(ans)