Private
prefixSum[i] = SUM(heights[j]), 0 <= j <= i
prefixSum[i], 0 <= i <= prefixSumValidIndex can be trusted
values[i] is the value at index i
prefixSum[i] = SUM(heights[j]), 0 <= j <= i