#K76827. Sum of Minimums in All Subarrays
Sum of Minimums in All Subarrays
Sum of Minimums in All Subarrays
Given a positive integer \( n \), consider the array \( A = [1, 2, 3, \ldots, n] \). For every contiguous subarray of \( A \), determine its minimum element and then compute the sum of all these minimum values. Note that since the array is strictly increasing, the minimum value of a subarray starting at index \( i \) and ending at index \( j \) is \( i \) (considering 1-indexed array). Thus, the sum can be derived by the formula:
\( S = \sum_{i=1}^{n} i \times (n-i+1) \)
Your task is to read an integer \( n \) from standard input and output the computed sum.
inputFormat
The input consists of a single integer \( n \) (\( 1 \leq n \leq 10^5 \)), representing the size of the array \( A = [1, 2, \ldots, n] \).
outputFormat
Output a single integer which is the sum of the minimum values of all contiguous subarrays of \( A \).
## sample1
1