Problem
Given a list of integers arr, look at every contiguous subarray and take its minimum. Return the sum of all those minimums. The answer can be huge, so return it modulo `10^9 + 7`.
Example 1
- Input
- arr = [3, 1, 2, 4]
- Output
- 17
The subarrays are [3] [1] [2] [4] [3,1] [1,2] [2,4] [3,1,2] [1,2,4] [3,1,2,4], with minimums 3, 1, 2, 4, 1, 1, 2, 1, 1, 1, which add up to 17.
Example 2
- Input
- arr = [11, 81, 94, 43, 3]
- Output
- 444
Constraints
1 <= arr.length <= 3 * 10^41 <= arr[i] <= 3 * 10^4