#C6468. Smallest Contiguous Subarray Sum
Smallest Contiguous Subarray Sum
Smallest Contiguous Subarray Sum
Given an array of integers, your task is to find the smallest sum of any contiguous subarray. Formally, if the array is represented as (a_1, a_2, \ldots, a_n), you need to compute: [ min_{1 \leq i \leq j \leq n} \left( \sum_{k=i}^{j} a_k \right) ] For instance, if the input is [3, -4, 2, -8, 5, -1], the smallest contiguous subarray sum is -10.
Note: The subarray must contain at least one element.
inputFormat
The first line contains an integer (n), representing the number of elements in the array. The second line contains (n) space-separated integers denoting the array elements.
outputFormat
Output a single integer: the smallest sum of any contiguous subarray.## sample
6
3 -4 2 -8 5 -1
-10