#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector in(n); int mi = 1 << 30; for (int i = 0; i < n; i++) { cin >> in[i]; mi = min(mi, in[i]); } vector a; for (int i = 0; i < n; i++) { if (in[i] > mi) a.push_back(in[i]); } sort(a.begin(), a.end()); n = a.size(); int ans = 0; for (int mask = 0; mask < (1 << n); mask++) { int cur = k; for (int i = 0; i < n; i++) { if ((mask >> i) & 1) cur %= a[i]; } cur %= mi; ans = max(ans, cur); } cout << ans << endl; return 0; }