Parallelization of the calculation of average