Create moving average in an array