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.io.*;
import java.util.*;

public class Main{
	static int inf=(int)1e7;
	static class segmentTree {
		int[]arr,sTree,lazy;
		int N;
		public segmentTree(int[]in) {//in array is 1-based array
			arr=in;
			int n=in.length;
			N=1;
			while(N<n) {
				N<<=1;
			}
			sTree=new int[N<<1];
			lazy=new int[N<<1];
			build(1,1,N);
		}
		void build(int node,int left,int right) {
			if(left==right) {
				if(left>=arr.length) {
					sTree[node]=inf;//the value that won't affect the required operation
				}
				else {
					sTree[node]=arr[left];
				}
				return;
			}
			int mid=(left+right)>>1;
			int leftChild=node<<1,rightChild=node<<1|1;
			build(leftChild, left, mid);
			build(rightChild, mid+1, right);
			sTree[node]=Math.min(sTree[leftChild],sTree[rightChild]);
		}
		
		void update_range(int i, int j, int val){
			update_range(1,1,N,i,j,val);
		}
		
		void update_range(int node,int curLeft,int curRight,int left,int right,int val) {
			if(curLeft>right || curRight<left)return;
			
			if(curLeft>=left && curRight<=right) {
				sTree[node] += val;			
				lazy[node] += val;
				return;
			}
			int mid=(curLeft+curRight)>>1;
			int leftChild=node<<1,rightChild=node<<1|1;
			propagate(node, curLeft, mid, curRight);
			update_range(leftChild, curLeft, mid, left, right,val);
			update_range(rightChild, mid+1, curRight, left, right,val);
			
			sTree[node]=Math.min(sTree[leftChild],sTree[rightChild]);
			
		}
		
		void propagate(int node, int b, int mid, int e){
			lazy[node<<1] += lazy[node];
			lazy[node<<1|1] += lazy[node];
			sTree[node<<1] += lazy[node];		
			sTree[node<<1|1] += lazy[node];		
			lazy[node] = 0;//the value that won't affect the required operation
		}
		int lastIdx() {
			return search(1, 1, N);
		}
		int search(int node,int curLeft,int curRight) {
			if(curLeft==curRight) {
				if(sTree[node]==0) {
					sTree[node]=inf;
					return curLeft;
				}
				return -1;
			}
			int mid=(curLeft+curRight)>>1;
			int leftChild=node<<1,rightChild=node<<1|1;
			propagate(node, curLeft, mid, curRight);
			int ans;
			if(sTree[rightChild]<=sTree[leftChild]) {
				ans=search(rightChild, mid+1, curRight);
			}
			else
				ans=search(leftChild, curLeft, mid);
			sTree[node]=Math.min(sTree[leftChild],sTree[rightChild]);
			return ans;
		}
	}
	static class fenwickTree {
		int INF=(int)2e9;
		int n;
		long[]ft;
		int log;
		fenwickTree(int z){
			
			ft=new long[z+1];
			n=z;
			
		}
		
		void updateSum(int idx,int k) {
			while(idx<=n) {
				ft[idx]+=k;
				idx+=(idx&(-1*idx));
			}
			
		}
		int querySum(int idx) {
			int sum=0;
			while(idx>0) {
				sum+=ft[idx];
				idx-=(idx&(-1*idx));
			}
			return sum;
		}
		
	}
	static void main() throws Exception{
		int n=sc.nextInt(),q=sc.nextInt();
		int[]in=new int[n+1];
		for(int i=1;i<=n;i++) {
			in[i]=i-sc.nextInt();
			if(in[i]<0) {
				in[i]=inf;
			}
		}
		segmentTree st=new segmentTree(in);
		fenwickTree ft=new fenwickTree(n+7);
		PriorityQueue<int[]>pq=new PriorityQueue<int[]>((x,y)->y[0]-x[0]);
		for(int i=0;i<q;i++) {
			pq.add(new int[] {sc.nextInt(),sc.nextInt(),i});
		}
		int[]ans=new int[q];
		int before=inf;
		while(true) {
			int idx=st.lastIdx();
			if(idx==-1)break;
			if(idx<before) {
				before=idx;
				while(!pq.isEmpty() && pq.peek()[0]>=idx) {
					int[]curQ=pq.poll();
					int last=n-curQ[1];
					ans[curQ[2]]=ft.querySum(last);
				}
			}
			
			ft.updateSum(idx, 1);
			if(idx+1<=n) {
				st.update_range(idx+1, n, -1);
			}
		}
		while(!pq.isEmpty()) {
			int[]curQ=pq.poll();
			int last=n-curQ[1];
			ans[curQ[2]]=ft.querySum(last);
		}
		for(int i=0;i<q;i++) {
			pw.println(ans[i]);
		}
		
		
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}