#include using namespace std; using ll = long long; template using vec = vector; template using vvec = vector>; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N,K; cin >> N >> K; vec A(N); for(auto& x:A) cin >> x; sort(A.begin(),A.end(),greater()); int ans = 0; for(int S=1;S<(1<>(N-1))&1){ int now = K; for(int i=0;i>i&1) now %= A[i]; ans = max(ans,now); } cout << ans << "\n"; }