Mean square value of exponential sums related to the representation of integers as sums of squares