You are given a sequence of integers. Your job is to take a continuous chunk of this sequence, such that the sum of its elements is maximized. You only need to return the maximum sum attained.
For example, suppose you are given the sequence (3, -10, 4, -1, 2, 3, 6, -7). You get the maximum sum by taking the elements (4, -1, 2, 3, 6) which sums to 14.
max_sum((-1, -9, 0, 8, -76, 5, 3)) ➞ 8
max_sum((3, -10, 4, -1, 2, 3, 6, -7)) ➞ 14
max_sum((1, -9, 0, -8, 76, 5, 43)) ➞ 124