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.*;

/*
polyakoff
*/

public class Main {

    static FastReader in;
    static PrintWriter out;
    static Random rand = new Random();
    static final int oo = (int) 2e9;
    static final long OO = (long) 4e18;
    static final int MOD = (int) 1e9 + 7;

    static Node[] roots;

    static class Node {
        int sum;
        Node left, right;

        Node() {
        }

        void pull() {
            sum = left.sum + right.sum;
        }
    }

    static Node copy(Node t) {
        Node newT = new Node();
        newT.sum = t.sum;
        newT.left = t.left;
        newT.right = t.right;
        return newT;
    }

    static Node build(int tl, int tr) {
        Node t = new Node();
        if (tl == tr) {
            t.sum = 0;
        } else {
            int tm = (tl + tr) / 2;
            t.left = build(tl, tm);
            t.right = build(tm + 1, tr);
            t.pull();
        }
        return t;
    }

    static int get(Node t, int tl, int tr, int l, int r) {
        if (r < tl || tr < l)
            return 0;
        if (l <= tl && tr <= r)
            return t.sum;
        int tm = (tl + tr) / 2;
        return get(t.left, tl, tm, l, r) + get(t.right, tm + 1, tr, l, r);
    }

    static Node upd(Node t, int tl, int tr, int pos, int val) {
        Node newT = copy(t);
        if (tl == tr) {
            newT.sum += val;
        } else {
            int tm = (tl + tr) / 2;
            if (pos <= tm)
                newT.left = upd(t.left, tl, tm, pos, val);
            else
                newT.right = upd(t.right, tm + 1, tr, pos, val);
            newT.pull();
        }
        return newT;
    }

    static void solve() {
        int n = in.nextInt();
        int q = in.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        roots = new Node[n + 1];
        roots[0] = build(0, n - 1);
        for (int i = 1; i <= n; i++) {
            int curr = i - a[i - 1];
            if (curr < 0) {
                roots[i] = copy(roots[i - 1]);
                continue;
            }
            int low = -1, high = i - 1;
            while (low < high) {
                int mid = (low + high + 1) / 2;
                if (get(roots[i - 1], 0, n - 1, mid, n - 1) >= curr)
                    low = mid;
                else
                    high = mid - 1;
            }
            if (low >= 0)
                roots[i] = upd(roots[i - 1], 0, n - 1, low, 1);
            else
                roots[i] = copy(roots[i - 1]);
        }

        for (int i = 0; i < q; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            out.println(get(roots[n - y], 0, n - 1, x, n - 1));
        }
    }

    public static void main(String[] args) throws FileNotFoundException {
        in = new FastReader(System.in);
//        in = new FastReader(new FileInputStream("sometext.txt"));
        out = new PrintWriter(System.out);
//        out = new PrintWriter(new FileOutputStream("output.txt"));

        int T = 1;
//        T = in.nextInt();
        while (T-- > 0)
            solve();

//        Thread thread = new Thread(null, () -> {
//            solve();
//        }, "Main", 1 << 28);
//        thread.start();
//        try {
//            thread.join();
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

        out.flush();
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        Integer nextInt() {
            return Integer.parseInt(next());
        }

        Long nextLong() {
            return Long.parseLong(next());
        }

        Double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }

    static void dbg(Object... args) {
        for (Object arg : args)
            out.print(" " + arg);
        out.flush();
    }

}