#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N, K; cin >> N >> K; vector A(N); for(auto &i : A) { cin >> i; } ranges::sort(A, ranges::greater()); ll ans = 0; for(ll i = 1; i < 1 << (N - 1); i++) { ll k = K; for(ll j = 0; j < N - 1; j++) { if(i >> j & 1) { k %= A[j]; } } k %= A.back(); ans = max(ans, k); } cout << ans << "\n"; }