It is well known among Romanian noblemen that the beauty of an integer array , , , , is the number of positive integers for which you can split the array into disjoint subarrays (sequences of consecutive elements) such that each element is contained in exactly one subarray and all the subarrays have the same minimum excluded element. The minimum excluded element of an integer array is the smallest strictly positive integer (greater than 0) that does not appear in the array.
You are given an integer array , , , and queries of the form , where for all .
For each query, you have to find the beauty of the array , , , .