The answer is all positive integers except 1, 2 and 4.
Let us call a positive integer good if it satisfies the condition given in the problem. We first show that if n is good, so is any multiple of n.
Let m=nk and x1,x2,…,xm be integers such that m∣xi for all 1≤i≤m. Then since n∣xi for all 1≤i≤m and n is good, there exist integers y1,y2,…,ym such that
i=nl+1∑n(l+1)xi2=i=nl+1∑n(l+1)yi2
for all 0≤l≤k−1 and n∤yi for all 1≤i≤m. Therefore we obtain that
i=1∑m=nkxi2=i=1∑m=nkyi2
and m=nk∤yi for all 1≤i≤m.
Lemma: Let n be a positive odd integer and x1,x2,…,xn be integers with at least one of them is not divisible by n. Then there exist integers y1,y2,…,yn such that none of them is divisible by n and
i=1∑n(nxi)2=i=1∑nyi2.
Proof: Without loss of generality we may assume that n∤x1. Let X=2∑i=1nxi. If n∤X, then replace x1 by −x1. As n∤x1 and n is odd, n∤4x1 and hence we may assume that n∤X. Then by the following identity
i=1∑n(nxi)2=i=1∑n(X−nxi)2
letting yi=X−nxi for all 1≤i≤n works.
For a positive odd integer n, if a positive integer a is sum of squares of n integers with each of them is divisible by n, then there exist integers x1,x2,…,xn and a positive integer r such that a=∑i=1n(nrxi)2 and n∤xi for some 1≤i≤n. Applying the lemma r times we can find integers y1,y2,…,yn such that a=∑i=1nyi2 and n∤yi for all 1≤i≤n.
Next we show that 8 is good. Let a be positive integer which is sum of squares of 8 integers with each of them is divisible by 8. Then 64∣a, hence a≥64 and a=12+42+42+42+x12+x22+x32+x42 for some integers x1,x2,x3,x4 by Lagrange's four-square theorem. Note that x12+x22+x32+x42≡7(mod8) and the only way to get 7 as sum of four quadratic residues in (mod 8) is 1+1+1+4. Therefore, 8∤xi for all 1≤i≤4.
Finally, we observe that 32=42+42+02+02 is a counterexample for 4 and we are done.