In haskell, this translates to:
let heights deltas = scanl (+) 0 deltas
let lowest_heights = scanl1 min . sums
let elevations xs = zipWith (-) (sums xs) (lowest_heights xs)
let max_elevation deltas = max (elevation deltas)
best = max_elevations [1, 2, 3, -2, -1, -4, 4, 6]
lowest_heights keeps track of the sea level, while the
elevations computes the elevation from the lowest height.
The maximum sum subarray will correspond to treating the elements of the array
as deltas, where we are trying to find the highest elevation. since elevation
is an integral (sum) of the deltas in height.