#C6143. Minimum Subarray Sum

    ID: 49871 Type: Default 1000ms 256MiB

Minimum Subarray Sum

Minimum Subarray Sum

You are given an array \(a\) consisting of \(n\) integers. Your task is to find the contiguous subarray (with at least one element) that has the minimum possible sum.

In mathematical terms, determine the value of \[ \min_{1 \le i \le j \le n} \sum_{k=i}^{j} a_k \] where \(a_k\) is the \(k^{th}\) element of the array.

Note: The subarray must contain at least one number.

inputFormat

The first line of input contains a single integer \(n\) representing the size of the array.

The second line contains \(n\) integers separated by spaces, representing the elements of the array.

outputFormat

Output a single integer, which is the minimum sum of any contiguous subarray.

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