arbitrary prefix sum and scatter