Let a_1, …, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are concatenated).

The weight of a is defined as the maximum number of elements you can remove.

You must answer q independent queries (x, y): after replacing the x first elements of a and the y last elements of a by n+1 (making them impossible to remove), what would be the weight of a?

Input

The first line contains two integers n and q (1 ≤ n, q ≤ 3 ⋅ 10^5) — the length of the array and the number of queries.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — elements of the array.

The i-th of the next q lines contains two integers x and y (x, y ≥ 0 and x+y < n).

Output

Print q lines, i-th line should contain a single integer — the answer to the i-th query.

Examples

Input


13 5
2 2 3 9 5 4 6 5 7 8 3 11 13
3 1
0 0
2 4
5 0
0 12


Output


5
11
6
1
0


Input


5 2
1 4 1 2 4
0 0
1 0


Output


2
0

Note

Explanation of the first query:

After making first x = 3 and last y = 1 elements impossible to remove, a becomes [×, ×, ×, 9, 5, 4, 6, 5, 7, 8, 3, 11, ×] (we represent 14 as × for clarity).

Here is a strategy that removes 5 elements (the element removed is colored in red):

  * [×, ×, ×, 9, \color{red}{5}, 4, 6, 5, 7, 8, 3, 11, ×] 
  * [×, ×, ×, 9, 4, 6, 5, 7, 8, 3, \color{red}{11}, ×] 
  * [×, ×, ×, 9, 4, \color{red}{6}, 5, 7, 8, 3, ×] 
  * [×, ×, ×, 9, 4, 5, 7, \color{red}{8}, 3, ×] 
  * [×, ×, ×, 9, 4, 5, \color{red}{7}, 3, ×] 
  * [×, ×, ×, 9, 4, 5, 3, ×] (final state) 



It is impossible to remove more than 5 elements, hence the weight is 5.
import java.util.*;
import java.io.*;
public class EdA {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int n = Integer.parseInt(st.nextToken());
 		int m = Integer.parseInt(st.nextToken());
 		BIT ans = new BIT(n);
 		int[] array = new int[n+1];
 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
 		for(int j = 1;j<=n;j++){
 			array[j] = Integer.parseInt(st2.nextToken());
 			array[j] = j-array[j];
 		}
 		int[] specialIndices = new int[n+1];
 		ArrayList<Query> queries = new ArrayList<Query>();
 		ArrayList<Query> original = new ArrayList<Query>();
 		Map<Query, Long> answers = new HashMap<Query, Long>();
 		for(int j =0 ;j<m;j++){
 			StringTokenizer st3 = new StringTokenizer(bf.readLine());
 			int x = Integer.parseInt(st3.nextToken());
 			int y = Integer.parseInt(st3.nextToken());
 			queries.add(new Query(x+1, n-y));
 			original.add(queries.get(j));
 			
 		}
 		Collections.sort(queries);
 		int index = 0;
 		int threshold = 0;
 		for(int j = 1;j<=n;j++){
 			
 			if (array[j]<=threshold && array[j] >=0){
 				threshold++;
 				int l = 0;
 				int r = j;
 				while(l < r){
 					int mid = (l+r+1)/2;
 					if (ans.query(mid,  n) >= array[j])
 						l = mid;
 					else
 						r = mid-1;
 				}
 				ans.add(l, 1);
 				//add one to the prefix of [0, ..., specialIndices[threhold-array[j]]
 			}
 			while(index < queries.size() && queries.get(index).r == j){
 				int left = queries.get(index).l;
 				answers.put(queries.get(index), ans.query(left, n));
 				index++;
 			}
 		}
 		for(int j = 0;j<m;j++){
 			out.println(answers.get(original.get(j)));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
	static class Query implements Comparable<Query>{
		private int l;
		private int r;
		public Query(int l, int r){
			this.l = l;
			this.r = r;
		}
		public int compareTo(Query other){
			if (r != other.r)
				return r - other.r;
			else
				return l - other.l;
		}
		
		
	}
	static class BIT {
        long[] tree;
        public BIT(int size) {
            tree = new long[size + 1];
        }
        public long sum(int i) {
            long ans = 0;
            while (i > 0) {
                ans += tree[i];
                i -= i & -i;
            }
            return ans;
        }
 
        public long query(int i, int j) {
            return sum(j) - sum(i - 1);
        }
 
        public void add(int i, long val) {
            while (i < tree.length) {
                tree[i] += val;
                i += i & -i;
            }
        }
 
        public void set(int i, long val) {
            add(i, val - query(i, i));
        }
    }
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	


