The Fair Nut has found an array a of n integers. We call subarray l … r a sequence of consecutive elements of an array with indexes from l to r, i.e. a_l, a_{l+1}, a_{l+2}, …, a_{r-1}, a_{r}. 

No one knows the reason, but he calls a pair of subsegments good if and only if the following conditions are satisfied:

  1. These subsegments should not be nested. That is, each of the subsegments should contain an element (as an index) that does not belong to another subsegment.
  2. Subsegments intersect and each element that belongs to the intersection belongs each of segments only once.



For example a=[1, 2, 3, 5, 5]. Pairs (1 … 3; 2 … 5) and (1 … 2; 2 … 3)) — are good, but (1 ... 3; 2 … 3) and (3 … 4; 4 … 5) — are not (subsegment 1 … 3 contains subsegment 2 … 3, integer 5 belongs both segments, but occurs twice in subsegment 4 … 5).

Help the Fair Nut to find out the number of pairs of good subsegments! The answer can be rather big so print it modulo 10^9+7.

Input

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the length of array a.

The second line contains n integers a_1, a_2, …, a_n (-10^9 ≤ a_i ≤ 10^9) — the array elements.

Output

Print single integer — the number of pairs of good subsegments modulo 10^9+7.

Examples

Input

3
1 2 3


Output

1


Input

5
1 2 1 2 3


Output

4

Note

In the first example, there is only one pair of good subsegments: (1 … 2, 2 … 3).

In the second example, there are four pairs of good subsegments: 

  * (1 … 2, 2 … 3) 
  * (2 … 3, 3 … 4) 
  * (2 … 3, 3 … 5) 
  * (3 … 4, 4 … 5)

Source: codeforces | Difficulty: VERY_HARD
Tags: Data structures

Implementation


Solutions: