#include using namespace std; using ll = long long; using ld = long double; #define rep(i, N) for (int i = 0; i < (int)(N); ++i) #define rrep(i, N) for (int i = (int)(N)-1; i >= 0; --i) #define debug(x) cout << #x << "=" << x << endl; constexpr int MOD=1000000007; constexpr ll INF = (1LL << 61) - 1; template inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;} template inline bool chmax(T &a, T b){if (a < b){a = b;return true;} return false;} template void fail(T v){cout << v << endl;exit(0);} //templte void solve(){ int N,K;cin>>N>>K; vector A(N); rep(i,N)cin>>A[i]; sort(A.rbegin(),A.rend()); int mx=0; rep(i,1<<(N-1)){ int now=K; rep(j,N)if(1&i>>j)now%=A[j]; chmax(mx,now%A.back()); } cout<