#C5889. Maximum Contiguous Subarray Sum

    ID: 49587 Type: Default 1000ms 256MiB

Maximum Contiguous Subarray Sum

Maximum Contiguous Subarray Sum

You are given an array of integers representing daily calorie intake. Your task is to compute the maximum possible sum of a contiguous subarray using Kadane's Algorithm. In mathematical terms, given an array \(A = [a_1, a_2, \dots, a_n]\), find the maximum value of \(\sum_{i=k}^{l} a_i\) for some \(1 \leq k \leq l \leq n\). Note that if the array is empty, the program should report an error.

Example:

Input:
5
1 -2 3 10 -4

Output: 13

</p>

inputFormat

The first line of input contains an integer \(n\) indicating the number of elements in the array. If \(n > 0\), the second line contains \(n\) space-separated integers representing the array. If \(n = 0\), the input is considered empty and the program should report an error.

outputFormat

Output a single integer representing the maximum sum of any contiguous subarray of the provided array.

## sample
5
1 -2 3 10 -4
13