#K52322. Maximum Contiguous Subarray Sum

    ID: 29284 Type: Default 1000ms 256MiB

Maximum Contiguous Subarray Sum

Maximum Contiguous Subarray Sum

Given an array of integers \(v_1, v_2, ..., v_n\), find the maximum sum of any contiguous subsequence.

This is a classic problem that can be efficiently solved using Kadane's Algorithm in \(O(n)\) time.

inputFormat

The first line contains a single integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers representing the array \(v\).

outputFormat

Output a single integer representing the maximum sum of a contiguous subsequence in the array.

## sample
9
-2 1 -3 4 -1 2 1 -5 4
6