#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

Given a sequence *A* of *N* integers, find the number of strictly increasing subsequences, modulo 10^{9} + 7.

## Input

The first line of input will contain a single integer, *N*.

The second line of input will contain *N* integers, representing the sequence *A*.

## Output

The output should contain one line with one integer, the number of strictly increasing subsequences, modulo 10^{9} + 7.

## Limits

Subtask 1 (30%): 1 ≤ N ≤ 10^{3}, 1 ≤ A_{i} ≤ 10^{3}.

Subtask 2 (10%): 1 ≤ N ≤ 10^{6}, A_{i} = i + 1. (A will be 1...N)

Subtask 3 (24%): 1 ≤ N ≤ 10^{6}, 1 ≤ A_{i} ≤ 10^{6}.

Subtask 4 (36%): 1 ≤ N ≤ 10^{6}, 1 ≤ A_{i} ≤ 10^{9}.

Subtask 5 (0%): Sample Testcases.

## Sample Input 1

4 1 2 3 4

## Sample Output 1

15

## Sample Input 2

5 1 6 2 4 3

## Sample Output 2

13

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 30 | 22 | 1.5s | 256MB | Minimum |

2 | 10 | 21 | 1.5s | 256MB | Minimum |

3 | 24 | 42 | 1.5s | 256MB | Minimum |

4 | 36 | 82 | 1.5s | 256MB | Minimum |

5 | 0 | 2 | 1.5s | 256MB | Minimum |

### Judge Compile Command

g++-7 ans.cpp -o nis -Wall -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512