Fence Job#10885

Fence Job

1 second
256 megabytes
Hard

Fred the Farmer wants to redesign the fence around his house. The fence consists of vertical wooden planks of distinct heights. The height of the -th plank is h_i~(1 \le h_i \le n).

To redesign the fence, Fred may repeatedly perform the following operation any number of times (possibly times):

Formally, after applying the operation to the segment [l, r], the heights of the planks in this segment become

h_i' = min(h_l, h_{l+1}, ..., h_r)~for~all~l \le i \le r

How many different fence designs can Fred obtain by applying this operation several times? Since the answer may be large, print it modulo 10^9 + 7.

Two fence designs and are considered different if there exists at least one plank whose height differs between and .

Input

The first line contains an integer n~(1 \le n \le 3000), the number of planks in the fence.

The second line contains distinct integers h_i~(1 \le h_i \le n, 1 \le i \le n), representing the initial heights of the planks.

Output

Print the number of different fence designs that can be obtained, modulo 10^9 + 7.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading