maxEndHere and maxStartHere arrays with the size of the input array arr.maxEndHere[0] to arr[0] and iterate through the array to fill in the rest of maxEndHere using the formula maxEndHere[i] = Math.max(arr[i], maxEndHere[i-1] + arr[i]).maxStartHere[arr.length - 1] to arr[arr.length - 1] and iterate backwards through the array to fill in the rest of maxStartHere using the formula maxStartHere[i] = Math.max(arr[i], maxStartHere[i+1] + arr[i]).max to the maximum value in maxEndHere array.i, calculate the sum if the element at index i is deleted: maxEndHere[i-1] + maxStartHere[i+1].max if the calculated sum is greater than the current max.max as the result.