array = [0, 1, 2, 3, 4]
reverse = lambda a: a[::-1]
cumsum = lambda a: [sum(a[:i + 1]) for i, x in enumerate(a)]
print(reverse(array))
print(cumsum(array))
reverse_cumsum = lambda a: reverse(cumsum(reverse(a)))
print(reverse_cumsum(array))
Perform a reverse cumulative sum on a numpy array