#include #include using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ll inf=10010010010010010; ll mod=998244353; int main(){ ll n,k; cin >> n >> k; vectora(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(),a.end()); ll syo=a[0]; reverse(a.begin(),a.end()); a.pop_back(); vectortwo(n+1,1); for (ll i = 1; i < two.size(); i++) { two[i]=two[i-1]*2; } ll ans=0; for (ll i = 0; i < two[n-1]; i++) { ll now=k; for (ll j = 0; j < n-1; j++) { if (i&two[j]) { now%=a[j]; } } ans=max(ans,now%syo); } cout << ans << endl; }