Change sum to always emit one element and add prefixSums