I solved this problem using binary search the answer, substracting it from each element of the array and finding its subarray with the largest sum. Then I came up with a different approach: we can iterate through possible lenghts of a subarray, pick one with the largest sum and update the answer. However, I don't know how to implement finding a subarray with length = 1..n and maximum sum fast enough to pass all tests.