ll n,k,a[20];ll f(ll d,ll x){return--d?max(f(d,x),f(d,x%a[d])):x%*a;}{rd(n,k,a(n));sortA(n,a);wt(f(n,k));}