Sum of every run's minimum
Given a list of integers nums, look at every non-empty contiguous run nums[i..j] (a list of n values has n·(n+1)/2 of them) and take its minimum. Return the sum of all those minimums. Values may be negative and may repeat; an empty list gives 0.
Aim for O(n): just listing every run is already O(n²).
Besides the tests, one large input (4,000 numbers) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
sum_of_run_minimums([3,1,2,4])→17sum_of_run_minimums([2,2,2])→12sum_of_run_minimums([4,-1,3])→3