finds the average of an array