Let a1<a2<⋯<an be the elements of A. The diameter of A is d(A)=an−a1. The minimum and maximum of A+A={x+y∣x,y∈A} are a1+a1 and an+an. Since A+A has 2n(n+1) elements, 2an−2a1+1≥2n(n+1)⟺d(A)≥4n2+4n−2≥4n2.
To prove the upper bound, we need to construct a set A with property P such that d(A)<n3. We do this recursively. Start with A={0,1} and we will adjoin elements to A. Suppose we already have a1=0<a2=1<⋯<an in A such that {a1,a2,…,an} has property P. Adjoining an+1 will generate n+1 more sums: a1+an+1,a2+an+1,…,an+1+an+1. All these sums must be different from any ai+aj, 1≤i≤j≤n. Moreover, an+1 must be different from all numbers ai, 1≤i≤n. This means that an+1∈/{ai+aj−ak∣1≤i≤j≤k}∪{2ai+aj∣1≤i,j≤n}=B. This set has no more than n3+2n(n+1) elements. So we may choose an+1 as the smaller number not in B, and so an+1≤n3+2n(n+1)<(n+1)3. Thus
d(A)=an+1−a1=an+1<(n+1)3.
Now we are going to prove the “bonus” part of the problem. Let p be a prime and consider A={k+2p⋅(k2modp)∣0≤k≤p−1}. We have
d(A)≤(p−1)+2p(p−1)=2p2−p−1<2p2. Moreover, r+2p(r2modp)+
s+2p(s2modp)=t+2p(t2modp)+u+2p(u2modp)⟺r+s=t+u
and r2modp+s2modp=t2modp+u2modp. So r−t=u−s and
r2−t2≡u2−s2(modp)⟺(r−t)(r+t)≡(u−s)(u+s)(modp)
⟺r−t≡u−s≡0(modp) or r+t≡u+s(modp), hence
r=t and s=u or r=u and s=t.