Domanda di colloquio di Google

An array is given. Find the sum of elements in every possible substring.