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 CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    void solve() {
        int T = 1;
        for (int i = 0; i < T; i++) {
            helper();
        }
    }

    private long[] fen;
    private int n;
    void initPara(int n) {
        fen = new long[1 + n];
    }
    void update(int p, long val) { //add val to tree node at p and all its parent, p is 0-based
        p++;
        for(int i = p; i <= n; i += i & -i)
            fen[i] += val;
    }
    long sum(int p) { //get sum between [0, p], p is 0-based
        long res = 0;
        p++;
        for(int i = p; i > 0; i -= i & -i)
            res += fen[i];
        return res;
    }

    class Query implements Comparable<Query> {
        int start;
        int end;
        int idx;
        public Query(int start, int end, int idx) {
            this.start = start;
            this.end = end;
            this.idx = idx;
        }

        @Override
        public int compareTo(Query o) {
            if (end != o.end) {
                return Integer.compare(end, o.end);
            }
            return Integer.compare(start, o.start);
        }

        @Override
        public String toString() {
            return start + " " + end;
        }
    }

    void helper() {
        n = nextInt();
        int q = nextInt();
        long[] arr = nextLongArr(n);
        for (int i = 0; i < n; i++) {
            arr[i] = (i + 1) - arr[i];
        }

        Query[] queries = new Query[q];
        for (int i = 0; i < q; i++) {
            int start = nextInt();
            int end = n - 1 - nextInt();
            queries[i] = new Query(start, end, i);
        }

        Arrays.sort(queries);
        initPara(n);

        int start = 0;
        long[] res = new long[q];
        for (int r = 0; r < n; r++) {
            if (arr[r] >= 0) {
                // [0, r] find the last i which fen[i] >= arr[i]
                int left = 0;
                int right = r + 1;
                while (left < right) {
                    int mid = (left + right) / 2;
                    long s = sum(mid);
                    if (s >= arr[r]) {
                        left = mid + 1;
                    } else {
                        right = mid;
                    }
                }

                // add 1 to [0, last], -> add 1 to 0 and -1 to last + 1
                update(0, 1);
                update(left, -1);
            }

            while (start < q && queries[start].end < r) {
                start++;
            }
            while (start < q && queries[start].end == r) {
                res[queries[start].idx] = sum(queries[start].start);
                start++;
            }
        }

        for (long v : res) {
            outln(v);
        }
    }

    void shuffle(long[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            long tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        outln(String.format("%.9f%n", val));
    }
    public CFA() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) {
        new CFA();
    }

    public long[] nextLongArr(int n) {
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() {
        return Double.parseDouble(nextToken());
    }
}