def cumsum(x, reverse):
    return scan((lambda c, x: ((c + x), (c + x))), 0, x, reverse=reverse)[1]
def cumsum(x, reverse):
    return scan((lambda c, x: ((c + x), (c + x))), 0, x, reverse=reverse)[1]