optimized PrefixSumCalculation