For every nonempty contiguous subarray of arr, take its minimum value. Return the sum of those minimums, modulo 1000000007.
Example 1:
Input: arr = [2,1,2]
Output: 8Explanation: The three length-1 subarrays contribute 2 + 1 + 2 = 5. The two length-2 subarrays each contribute 1, and the whole array contributes 1, for a total of 8.
Example 2:
Input: arr = [5]
Output: 5Explanation: The only nonempty subarray is [5], whose minimum is 5.
Example 3:
Input: arr = [4,4,4]
Output: 24Explanation: There are 3 + 2 + 1 = 6 nonempty subarrays. Each has minimum 4, so the sum is 6 * 4 = 24.
Constraints:
1 <= arr.length <= 300001 <= arr[i] <= 30000