#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair P; typedef pair PL; constexpr int mod = 1e9 + 7; constexpr int INF = 1e9; int main() { int n, k; cin >> n >> k; vector a(n); rep(i,n) cin >> a[i]; sort(a.begin(), a.end(), greater()); int res = 0; for (int bit = 0; bit < (1 << (n - 1)); bit++) { int tmp = k; for (int i = 0; i < n - 1; i++) { if (bit & (1 << i)) tmp %= a[i]; } res = max(res, tmp % a[n - 1]); } cout << res << endl; return 0; }