#define DEBUGGING // Enables DEBUG macro. #include using namespace std; using i64 = long long; using u64 = unsigned long long; #define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i) #ifndef DEBUGGING #define debug(...) #define DEBUG(...) #else template void debug(T value) { std::cerr << value; } template void debug(T value, Ts... args) { std::cerr << value << ", "; debug(args...); } #define DEBUG(...) \ do { \ cerr << " (L" << __LINE__ << ") "; \ cerr << #__VA_ARGS__ << ": "; \ debug(__VA_ARGS__); \ cerr << endl; \ } while (0) #endif const i64 INF = 1LL << 40; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K; cin >> N >> K; vector A(N); i64 mx = INF; for (auto& x : A) { cin >> x; mx = min(mx, x); } i64 ans = 0; auto solve = [&](auto rec, int i, i64 val) -> void { if (i == N) return; if (val < mx) { if (ans < val) ans = val; return; } rec(rec, i + 1, val); rec(rec, i + 1, val % A[i]); }; solve(solve, 0, K); cout << ans << endl; }