#K9211. Smallest Contiguous Sublist Sum
Smallest Contiguous Sublist Sum
Smallest Contiguous Sublist Sum
Given a linked list represented by a sequence of integers, your task is to find the smallest sum of any non-empty contiguous sublist. Formally, if the list is represented as \(a_1, a_2, \dots, a_n\), you need to compute
$$minSum = \min_{1 \leq i \leq j \leq n} \sum_{k=i}^{j}{a_k} $$This problem is a variant of the famous Kadane's algorithm problem, but instead of finding the maximum sum contiguous subarray, you must find the minimum.
Note: A contiguous sublist must contain at least one element.
inputFormat
The input is provided via stdin and consists of two lines:
- The first line contains a single integer \(n\) representing the number of nodes in the linked list.
- The second line contains \(n\) space-separated integers representing the values of the nodes.
outputFormat
Output via stdout a single integer which is the smallest sum of any contiguous sublist of the linked list.
## sample1
1
1