Sum of Subarray Minimums
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given an array of integers. Find the sum of for every pair , where .
Input
The first line contains the size of array . The second line contains integers — the elements of array.
Output
Print the the sum of modulo .
Examples
Consider the first test case.
Subarrays are .
Minimums are . Their sum is .
Input #1
Answer #1
Input #2
Answer #2
Submissions 164
Acceptance rate 23%