Averages all elements in an array.