Distributed Algorithm for calculating Sum of Squares