#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 1000000000000000000 int main(){ int N,K; cin>>N>>K; vector A(N); for(int i=0;i>A[i]; sort(A.rbegin(),A.rend()); int ans = 0; for(int i=0;i<(1<>j)&1){ t %= A[j]; } } t %= A.back(); ans = max(ans,t); } cout<