function to get all possible sum of squares