Need help to solve a problem asked in a recent OA.
Разница между en1 и en2, 2 символ(ов) изменены
Hello everyone, recently I was giving an OA in a company and this problem came up.↵

**Problem:**↵
You are given an array A containing N positive integers. The task involves calculating the special value of the array.↵
The special value (S) is sum of product of smallest and largest number of all the possible subarray of A.↵
Find the special value (S) of A. Since the answer can be very large return it modulo 10^9+7.↵

**Constraints:**↵
1 <= N <= 10^5, ↵
1 <= A[i] <= 10^9↵

**Test Case 1:**↵
A = [
31,4,2]↵
Ans = 37↵

**Test Case 2:**↵
A=[1,2]↵
Ans = 7↵

**Test Case 3:**↵
A = [2,2]↵
Ans = 12↵

Can anyone explain me the approach to solve this. Thanks in advance.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский toxik 2025-07-12 22:11:04 2 Tiny change: ':**\nA = [3,4,2]\nAns' -> ':**\nA = [1,4,2]\nAns'
en1 Английский toxik 2025-07-12 21:56:38 720 Initial revision (published)