//#include #include using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() const int MAX = 1e9; const int MIN = -1*1e9; const ll MAXLL = 1e18; const ll MINLL = -1*1e18; ll N,Ans = MIN; vector V(21); map>,bool> F; void DFS(vector A, int last, ll K) { if(F[{last,A}]) return; F[{last,A}] = true; if(K <= Ans) return; bool f = false; for(int i = 0; i < N; i++) { if(A[i]) continue; f = true; A[i] = true; DFS(A,i,K%V[i]); A[i] = false; } if(!f) { Ans = max(Ans,K); return; } return; } int main() { ll K; cin >> N >> K; for(int i = 0; i < N; i++) cin >> V[i]; vector A(21); DFS(A,-1,K); cout << Ans << endl; return 0; }