find the sum of the squares of an n element vector