Given an Array arr of Integers having length N, find the maximum value of min(A[i,j])×sum(A[i,j]) for all 0≤i≤j<N where A[i,j] denotes the non-empty subarray [Ai,Ai+1,Ai+2,...,Aj−1,Aj].
Since the product may be large, return the product modulo 109+7.
Note:
Input Format:
Output Format:
Constraints: