(1) Obviously the number of the values of S is finite, so the maximum and minimum exist. Suppose x1+x2+x3+x4+x5=2006 such that S=∑1≤i<j≤5xixj reaches the maximum, we must have
∣xi−xj∣≤1,(1≤i,j≤5).
Otherwise, assume that this does not hold. Without loss of generality, suppose x1−x2≥2. Let x1′=x1−1, x2′=x2+1, xi′=xi (i=3,4,5). We have
x1′+x2′+x3′+x4′+x5′=x1+x2+x3+x4+x5=2006,
S=1≤i<j≤5∑xixj=x1x2+(x1+x2)(x3+x4+x5)+x3x4+x3x5+x4x5,
S′=x1′x2′+(x1′+x2′)(x3+x4+x5)+x3x4+x3x5+x4x5.
So
S′−S=x1′x2′−x1x2>0.
This contradicts the assumption that S is the maximum.
Therefore ∣xi−xj∣≤1 for 1≤i,j≤5. And it is easy to check that S reaches the maximum when
x1=402,x2=x3=x4=x5=401.
(2) If we neglect the order in x1,x2,x3,x4,x5, there could only be three cases:
(a) 402,402,402,400,400;
(b) 402,402,401,401,400;
(c) 402,401,401,401,401.
That satisfy x1+x2+x3+x4+x5=2006 and ∣xi−xj∣≤2.
Cases (b) and (c) can be obtained from Case (a) by setting xi′=xi−1, xj′=xj+1. What we have done in (1) tells us that each step like this will make S′=∑1≤i<j≤5xi′xj′ greater. So S is the minimum in Case (a), i.e. x1=x2=x3=402, x4=x5=400.