Here’s my attempt at explaining the approach. The problem is the **maximum sum subarray** problem, which you want to solve by a divide and conquer approach, which is what a segment tree does.

For a given range A, you split it into two pieces, the left half L and the right half R. Naturally the maximum sum subarray in A can lie either 1) completely in L, or lie 2) completely in R, or 3) cross over from L to R. Solve recursively for the two halves. We get the maximum sum subarrays for the left half as L.maxsum and the right half as R.maxsum, and now we know the first 2 of the 3 options just like that *snaps fingers*

How do we get the third option? A range that extends from L to R can be broken into a suffix of L and a prefix of R. So if we know the maximum suffix sum in L as L.suffixsum and the maximum prefix sum in R as R.prefixsum, the sum of those 2 values will give us the maximum sum subarray extending from L to R, which covers option 3. So we get

tree[index].maxsum = max(max(tree[2\*index+1].maxsum, tree[2\*index+2].maxsum),
tree[2\*index+1].suffixsum + tree[2\*index+2].prefixsum);

Now since we have incorporated 2 new values (prefixsum and suffixsum), the parent range of A will also require these from A. So now we need to calculate A.prefixsum and A.suffixsum. The maximum sum prefix of A can be 1) the maximum sum prefix of L, or 2) cover the whole of L and extend into R. Option 1 is simply L.prefixsum, and option 2 is \sum L + R.prefixsum. Similarly, the maximum sum suffix of A is either R.suffixsum or \sum R + L.suffixsum. So now it seems we need another value to represent a range, which is the sum of that range. So we have

tree[index].prefixsum = max(tree[2\*index+1].prefixsum,
tree[2\*index+1].sum + tree[2\*index+2].prefixsum);
tree[index].suffixsum = max(tree[2\*index+2].suffixsum,
tree[2\*index+2].sum + tree[2\*index+1].suffixsum);

And for the sum it is simply

tree[index].sum = tree[2\*index+1].sum + tree[2\*index+2].sum;

Well, that covers the whole thing, I hope it is clear why we require the 4 values in one node of the segment tree. Also you can see that the calculation of `tree[index].maxsum`

in the link you provided can be simplified as I have described above. Feel free to ask if anything is not clear