Generalize the concatFlushSum function.