Young Luka is about to enter a house with the evil witch Marica inside. As soon as he enters the house,
she asks him questions about her array of
It is Luka's task to answer for each query what the longest contiguous sub-array of that contiguous sub-array (it can be the entire sub-array) having the property of being magical. An array is called
magical if all the values are between the values of the first and last number in that array. For example,
Input
The first line of input contains the integer
The second line contains
The third line contains the integer
Each of the following
Output
The
Scoring
In test cases worth
Sample Input 1
5
5 4 3 3 2
3
1 2
1 1
2 4
Sample Output 1
2
1
3
Sample Input 2
6
6 6 5 1 6 2
3
4 5
4 6
1 4
Sample Output 2
2
2
4
Comments