#C9680. Maximum Subarray Sum

    ID: 53800 Type: Default 1000ms 256MiB

Maximum Subarray Sum

Maximum Subarray Sum

Given an array of integers, find the maximum sum of any contiguous subarray. The subarray must be continuous and can consist of one or more elements.

You are required to solve the problem using Kadane's algorithm. The mathematical formulation is given by: $$ \max_{1 \leq i \leq j \leq n} \sum_{k=i}^{j} a_k $$, where (a_k) represents the elements of the array.

If the array is empty, output 0.

inputFormat

Input is provided via stdin. The first line contains an integer (n), the number of elements in the array. If (n > 0), the second line contains (n) space-separated integers; otherwise, the array is empty.

outputFormat

Print on stdout a single integer representing the maximum sum of any contiguous subarray of the given array.## sample

1
5
5