static method to calculate the sum of a one dimensional array