ll@N,@K,@A[N],D[1d6],L,a=0;rep(i,N){L=Divisor(A[i],D);rep[D](d,L)a>?=d*(K>=sum[j,0,N](min(A[j]%d,d-A[j]%d)));}wt(a);