#K8411. Maximum Sublist Sum
Maximum Sublist Sum
Maximum Sublist Sum
Given an array of integers, your task is to compute the maximum sum of any continuous subarray (also known as a sublist). Formally, you need to find the maximum value of \(\sum_{i=l}^{r} a_i\) over all indices \(0 \leq l \leq r < n\). In the case where the list is empty, the result is defined as 0.
This problem can be solved efficiently using Kadane's algorithm, which iterates through the list and dynamically computes the maximum subarray ending at each position.
inputFormat
The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers. If \(n = 0\), the array is empty.
outputFormat
Output a single integer — the maximum sum of any contiguous subarray.
## sample9
-2 1 -3 4 -1 2 1 -5 4
6