#include using namespace std; int main(int argc, const char *argv[]) { int n, k; cin >> n >> k; vector va(n); for (int i = 0; i < n; ++i) { cin >> va[i]; } int ans = 0; for (int i = 0; i < n; ++i) { int a = va[i], md = k % a; int min_a = -1; for (int j = 0; j < n; ++j) { if (i == j) { continue; } if (min_a < 0 || va[j] < min_a) { min_a = va[j]; } } if (md < min_a) { ans = max(ans, md); } } cout << ans << '\n'; }