For any finite set S of positive integers, let
D(S)=x∈S∏x−x∈S∑x2.
If D(A)=0, then we take B=A.
If D(A)<0, then let m=maxA. Write Ak′=A∪{m+1,m+2,…,m+k}. Then there is a positive integer k such that
−D(A)<(m+1)k−(k3+2mk2+m2k)=(m+1)k−k(m+k)2≤D(Ak′)−D(A)
and hence D(Ak′)>0. Thus, it suffices to find a finite set B containing Ak′ such that D(B)=0, because then B contains A as well. This reduces the problem to the next and final case.
Assume that D(A)>0, and write A0=A. Define Ak+1=Ak∪{∏x∈Akx−1} recursively for k=0,1,…,D(A)−1. If D(Ak)>0, we have Ak={1} and hence
maxAk<x∈Ak∑x2=x∈Ak∏x−D(Ak)<x∈Ak∏x.
Therefore, ∏x∈Akx−1>maxAk and Ak+1 has one more element than Ak. It follows that
D(Ak+1)=x∈Ak+1∏x−x∈Ak+1∑x2=x∈Ak∏x(x∈Ak∏x−1)−x∈Ak∑x2−(x∈Ak∏x−1)2=x∈Ak∏x−x∈Ak∑x2−1=D(Ak)−1.
Because D(A0)>0, it follows that D(Ak)=D(A)−k>0 for k<D(A) and that D(AD(A))=0. Taking B=AD(A) completes the proof.