#include #define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i)) #define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i)) #define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i)) #define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i)) #define REP(i, n) FOR((i), 0, (n)) #define REPe(i, n) FORe((i), 1, (n)) #define REPo(i, n) FORe((i), 0, (n)) #define rREP(i, n) rFOR((i), 0, (n)) #define rREPe(i, n) rFORe((i), 1, (n)) #define rREPo(i, n) rFORe((i), 0, (n)) #define rep(i, n) FOR((i), 0, (n)) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define fi first #define se second #define dup(x, y) (((x)+(y)-1)/(y)) #define vc(T) vector #define vv(T) v(v(T)) using namespace std; using ll = long long; using P = pair; using pll = pair; using T = tuple; using vi = vector; using vvi = vector; using vl = vector; using vs = vector; using vp = vector

; using vt = vector; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { int n, k; cin>>n>>k; vi a(n); REP(i, n) cin>>a[i]; sort(all(a)); int ans = 0; do { int tmp = k; REP(i, n) tmp %= a[i]; chmax(ans, tmp); }while (next_permutation(all(a))); cout << ans << endl; return 0; }