Marisa needs to pick mushrooms in a forest. The forest can be represented as a straight line with n positions from 1 to n. At position i in the forest, a type of mushroom ai grows.
There are q days. On the i-th day, she will stand at position pi. She wants to pick mushrooms of types li to ri, one of each type if it exists. Instead of moving physically, she can use mushroom-picking magic. If she is standing at position x, she can pick a mushroom at position y at a cost of |x−y|.
For each day, help her calculate the minimum cost to pick the mushrooms.
### Input
- The first line contains two integers n and q.
- The second line contains n integers ai.
- The next q lines each contain three integers pi, li, and ri.
### Output
- For each day, calculate the minimum cost for Marisa to pick the mushrooms.
### Constraints
- 1≤n,q≤2×105.
- 1≤l,r,p,ai≤n.
### Example
Input:
5415313334425313525
Output:
0313
### Subtasks
- 30 of the tests have 1≤n,q≤1000.
- 10 of the tests have ai=i.
- 30 of the tests have ∀ili=1,ri=n.
- The remaining 20 have no additional constraints.