#include using namespace std; using lint = long long; const lint inf = 1LL << 60; const lint mod = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, k; cin >> n >> k; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end(), greater<>()); lint ret = 0; for (int i = 1; i < 1 << n; ++i) { lint t = k; for (int j = 0; j < n; ++j) { if (i >> j & 1 || j == n - 1) { t %= a[j]; } } ret = max(ret, t); } cout << ret << "\n"; return 0; }