#include #include #include using namespace std; int solve(vector& a, int k, int i=0) { while (i < a.size() && a[i] > k) i++; if (i == a.size()) return k; if (i == a.size() - 1) return k % a[i]; return max(solve(a, k % a[i], i+1), solve(a, k, i+1)); } int main() { 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()); cout << solve(a, k) << endl; }