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