Calculate sum of the elements of array