CSES - Distinct Values Splits
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You are given an array of nn integers. Your task is to count the number of ways to split the array into continuous segments such that all segments consists of distinct values.

Input

The first line has an integers nn: the size of the array.

The next line has nn integers x1,x2,,xnx_1, x_2,\dots, x_n: the contents of the array.

Output

Print one integer: the answer to the problem modulo 109+710^9 + 7.

Constraints

  • 1n21051 \le n \le 2 \cdot 10^5
  • 1xi1091 \le x_i \le 10^9

Example

Input:

4
1 2 1 3

Output:

6

Explanation: There are six valid splits:

  • [1],[2],[1],[3][1], [2], [1], [3]
  • [1],[2],[1,3][1], [2], [1, 3]
  • [1],[2,1],[3][1], [2, 1], [3]
  • [1],[2,1,3][1], [2, 1, 3]
  • [1,2],[1],[3][1, 2], [1], [3]
  • [1,2],[1,3][1, 2], [1, 3]