#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N = 1e6 + 10,M=210;
const int inf=0x3f3f3f3f,mod=998244353;
void solve() {
int n,k;
cin>>n>>k;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin>>a[i];
}
vector<int> pre(n + 1), suf(n + 2);
for (int i = 1; i <= n; i++) {
pre[i] = __gcd(pre[i - 1], a[i]);
}
for (int i = n; i >= 1; i--) {
suf[i] = __gcd(suf[i + 1], a[i]);
}
int ans = pre[n];
for (int i = 1; i <= n; i++) {
if (pre[i] == pre[i - 1]) continue;
int g = 0;
for (int j = i; j <= n; j++) {
g = __gcd(g, a[j] + k);
ans = max(ans, __gcd(pre[i - 1], __gcd(g, suf[j + 1])));
}
}
cout << ans << '\n';
}