Implementation of sum(array)