LearnPy Hub
← Arena
AdvancedRating 1700

Sum of All Block Minimums

Add up the minimum of every block of consecutive numbers. Print the total modulo 1 000 000 007.

Input

n, then n positive integers.

Output

One integer.

Sample 1

Input
4
3 1 2 4
Output
17

Sample 2

Input
5
11 81 94 43 3
Output
444
solution.py
Output appears here
Sum of All Block Minimums · Python Arena problem · LearnPy Hub