Sum of Subarray Minimums

Given an array of integers arg1, find the sum of min(b) over every contiguous subarray b of arg1. Since the answer may be large, return the answer modulo 10^9 + 7.

Examples
Input: [3,1,2,4]
Output: 17
Hints

Sum of Subarray Minimums

Given an array of integers `arg1`, find the sum of `min(b)` over every contiguous subarray `b` of `arg1`. Since the answer may be large, return the answer modulo `10^9 + 7`.