#include using namespace std; using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vs = vector; #define endl ('\n') inline vector range(int64_t stop){vectorv(stop);iota(v.begin(),v.end(),0LL);return v;} inline vector range(int64_t start,int64_t stop){vectorv(stop-start);iota(v.begin(),v.end(),start);return v;} inline vector range(int64_t start,int64_t stop,int64_t step){int s=step>0?(stop-start+step-1)/step:(stop-start+step+1)/step;if(s<=0)return {};vectorv(s);for(int i=0;i> n >> k; vi A(n); for(auto i:range(n))cin >> A[i]; sort(A.begin(), A.end(), greater()); int ans = 0; for(auto i:range(n-1, -1, -1)){ int temp = k; for(auto j:range(i, n)){ temp %= A[j]; } ans = max(ans, temp); } cout << ans << endl; return 0; }