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 Rating{
	private static Scanner in=new Scanner(System.in);
	private static int N=(int)(3e5)+7;
	private static int sum[]=new int[N*4];
	public static class Segment{
		int l,r,id;
	}
	public static class mycmp implements Comparator<Segment>  
	{  
		public int compare(Segment A, Segment B)   
		{  
			return A.r-B.r;
		}  
	} 
	public static int lson(int rt) {
		return rt*2;
	}
	public static int rson(int rt) {
		return rt*2+1;
	}
	private static void update(int rt) {sum[rt]=sum[lson(rt)]+sum[rson(rt)];}
	private static void modify(int rt,int l,int r,int pos,int val) {
		if(l==r) {sum[rt]+=val;return;}int mid=l+r>>1;
		if(pos<=mid)modify(lson(rt),l,mid,pos,val);else modify(rson(rt),mid+1,r,pos,val);update(rt);
	}
	private static int query(int rt,int l,int r,int a,int b) {
		if(a<=l&&r<=b)return sum[rt];int mid=l+r>>1;int res=0;
		if(a<=mid)res=query(lson(rt),l,mid,a,b);if(b>mid)res+=query(rson(rt),mid+1,r,a,b);return res;
	}
	private static int ask(int rt,int l,int r,int k) {
		if(l==r)return l;int mid=l+r>>1;
		if(sum[rson(rt)]>=k)return ask(rson(rt),mid+1,r,k);else return ask(lson(rt),l,mid,k-sum[rson(rt)]);
	}
    public static void main(String args[]) {
    	int n=in.nextInt(),m=in.nextInt(),arr[]=new int[N],pos[]=new int[N];Arrays.fill(pos, 0);
    	for(int i=1;i<=n;++i) {
    		arr[i]=in.nextInt();
    		if(arr[i]-i<=0)arr[i]=i-arr[i]+1;else arr[i]=0;
    		if(arr[i]==1) {
    			pos[i]=i;modify(1,1,n,i,1);
    		}else if(arr[i]!=0){
    			if(sum[1]>=arr[i]-1) {
    				pos[i]=ask(1,1,n,arr[i]-1);
    				modify(1,1,n,pos[i],1);
    			}
    		}
    	}Segment q[]=new Segment[m+7];int ans[]=new int[m+7];Arrays.fill(sum, 0);
    	for(int i=1;i<=m;++i)q[i]=new Segment();
    	for(int i=1;i<=m;++i) {
    		q[i].l=in.nextInt()+1;
    		q[i].r=n-in.nextInt();
    		q[i].id=i;
    	}Arrays.sort(q,1,m+1,new mycmp());
    	for(int i=1,j=1;i<=m;++i) {
    		while(j<=n&&j<=q[i].r) {
    			if(pos[j]!=0)modify(1,1,n,pos[j],1);
    			++j;
    		}
    		ans[q[i].id]=query(1,1,n,q[i].l,q[i].r);
    	}
    	for(int i=1;i<=m;++i)System.out.println(ans[i]);
    }
}