Max Subarray Sum 2

when we are taking i-1 then for i =0 it will be cumsum[-1]. Will it not take garbage values???.

how to think this cumSum array and currentSum = cumSum[j] - cumSum[i-1]
logic.The code is working but do we have to remember this logic.