340. Efficient Subarray Sum
Adarsh has a given array of integers arr and wants to find the sum of the smallest element from each subarray. However, this process takes a long time. Help Adarsh find the result more efficiently. The answer should be returned modulo 10^9 + 7.
The first line of input should contain an integer N, the size of the array. The second line should contain N integers representing the elements of the array.
The output should be the sum of the smallest element of each possible subarray.
4 3 1 2 4