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.
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1404C
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int Q = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
         {
            arr[i] = Integer.parseInt(st.nextToken());
            arr[i] = i-arr[i]+1;
         }
         Query[] qrr = new Query[Q];
         for(int i=0; i < Q; i++)
         {
            st = new StringTokenizer(infile.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            qrr[i] = new Query(a, N-b-1, i);
         }
         Arrays.sort(qrr);
         LazySegTree dp = new LazySegTree(N+3);
         int[] res = new int[Q];
         if(arr[0] == 0)
            dp.update(0, 0, 1);
         int border = 0;
         for(Query q: qrr)
         {
            while(q.right > border)
            {
               border++;
               //print(dp, N);
               if(arr[border] >= 0 && dp.query(0, border-1) >= arr[border])
               {
                  int low = 1;
                  int high = border;
                  while(low != high)
                  {
                     int mid = (low+high)/2;
                     if(dp.query(mid, border) >= arr[border])
                        low = mid+1;
                     else
                        high = mid;
                  }
                  dp.update(0, low-1, 1);
                  if(arr[border] == 0)
                     dp.update(border, border, 1);
               }
            }
            res[q.dex] = dp.query(q.left, q.left);
         }
         StringBuilder sb = new StringBuilder();
         for(int x: res)
            sb.append(x+"\n");
         System.out.print(sb);
      }
      public static void print(LazySegTree fuck, int N)
      {
         for(int i=0; i < N; i++)
            System.out.print(fuck.query(i,i)+" ");
         System.out.println();
      }
   }
   class Query implements Comparable<Query>
   {
      public int left;
      public int right;
      public int dex;
      
      public Query(int a, int b, int c)
      {
         left = a;
         right = b;
         dex = c;
      }
      public int compareTo(Query oth)
      {
         return right-oth.right;
      }
   }
   class LazySegTree
   {
      //definitions
      private int NULL = -1;
      //ds stuff
      private int[] tree;
      private int[] lazy;
      private int length;
      
      public LazySegTree(int N)
      {
         length = N;   int b;
         for(b=0; (1<<b) < length; b++);
         tree = new int[1<<(b+1)];
         lazy = new int[1<<(b+1)];
      }
      public int query(int left, int right)
      {
         //left and right are 0-indexed
         return get(1, 0, length-1, left, right);  
      }
      private int get(int v, int currL, int currR, int L, int R)
      {
         if(L > R)
            return NULL;
         if(L <= currL && currR <= R)
            return tree[v];
         propagate(v);
         int mid = (currL+currR)/2;
         return comb(get(v*2, currL, mid, L, Math.min(R, mid)),
            get(v*2+1, mid+1, currR, Math.max(L, mid+1), R));
      }
      public void update(int left, int right, int delta)
      {
         add(1, 0, length-1, left, right, delta);
      }
      private void add(int v, int currL, int currR, int L, int R, int delta)
      {
         if(L > R)
            return;
         if(currL == L && currR == R)
         {
            //exact covering
            tree[v] += delta;
            lazy[v] += delta;
            return;
         }
         propagate(v);
         int mid = (currL+currR)/2;
         add(v*2, currL, mid, L, Math.min(R, mid), delta);
         add(v*2+1, mid+1, currR, Math.max(L, mid+1), R, delta);
         tree[v] = comb(tree[v*2], tree[v*2+1]);
      }
      private void propagate(int v)
      {
         //tree[v] already has lazy[v]
         if(lazy[v] == 0)
            return;
         tree[v*2] += lazy[v];
         lazy[v*2] += lazy[v];
         tree[v*2+1] += lazy[v];
         lazy[v*2+1] += lazy[v];
         lazy[v] = 0;
      }
      private int comb(int a, int b)
      {
         return Math.max(a,b);
      }
   }