Calculate the sum of values in an array