#C5845. Maximum Subarray Sum

    ID: 49539 Type: Default 1000ms 256MiB

Maximum Subarray Sum

Maximum Subarray Sum

Given an array of integers, your task is to calculate the maximum possible sum of any contiguous subarray. This problem is a classic example that can be efficiently solved using Kadane's algorithm.

Explanation: A contiguous subarray is a sequence of consecutive elements from the array. For instance, given the array [8, -19, 5, -4, 20], the subarray [5, -4, 20] gives the maximum sum 21.

Note: The subarray must contain at least one element.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer N, representing the number of elements in the array. The second line contains N space-separated integers denoting the elements of the array.

outputFormat

Print a single integer to standard output (stdout), which is the maximum sum of any contiguous subarray.## sample

1
1
1