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.ByteArrayInputStream;
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class E_3 {
	public static void main(String[] args) throws Exception {
		new E_3().go();
	}

	int USE_FILE = 0;
	String INPUT = "13 5\r\n" +
			"2 2 3 9 5 4 6 5 7 8 3 11 13\r\n" +
			"3 1\r\n" +
			"0 0\r\n" +
			"2 4\r\n" +
			"5 0\r\n" +
			"0 12";

	void solve(int caseNr) {
		int n = in.nextInt();
		int q = in.nextInt();
		int[] a_arr = na_offset(n);

		int[] a = new int[n+1];
		for (int i = 1; i <= n; i++) {
			a[i] = i - a_arr[i];
		}

		int[] ans = new int[q];
		int[] leftBound = new int[q];
		List<List<Integer>> endHere = new ArrayList<>();
		int[] BIT = new int[n+1];

		for (int i = 0; i <= n+1; i++) {
			endHere.add(new ArrayList<>());
		}

		for (int i = 0; i < q; ++i) {
			int x = in.nextInt();
			int y = in.nextInt();
			int l = 1+x;
			int r = n-y;
			leftBound[i] = l;
			endHere.get(r).add(i);
		}

		int global = 0;
		for (int r = 1; r <= n; ++r) {
			int target = a[r];
			if (target >= 0) {
				int pos = 0;
				int cur = global;
				for (int jump = 1 << lg2(n); jump >= 1; jump /= 2)
					if (pos+jump <= r && cur - BIT[pos+jump] >= target) {
						pos += jump;
						cur -= BIT[pos];
					}
				++global;
				for (int i = pos+1; i <= n; i += i & -i) {
					++BIT[i];
				}
			}
			for (int iQuery : endHere.get(r)) {
				ans[iQuery] = global;
				for (int i = leftBound[iQuery]; i > 0; i -= i & -i) {
					ans[iQuery] -= BIT[i];
				}
			}
		}


		for (int i = 0; i < q; ++i) {
			out.println(ans[i]);
		}

		return;
	} // end of solve2



	int lg2(int n) {
		return (n > 1) ? 1 + lg2(n / 2) : 0;
	}


	// ---------------------------------------------------------------------------------------------- //


	void testCases() {
		int t = 1;
		for (int i=1; i<=t; i++) {
			solve(i);
		}
		out.flush();
	}


	// ---------------------------------------------------------------------------------------------- //

	private int[] na_offset(int n) {
		int[] a = new int[n+1];
		for (int i=1; i<=n; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}


	// ---------------------------------------------------------------------------------------------- //


	void go() throws Exception {
		if (LOCAL && USE_FILE == 0) {
			//  needs to be set locally or expects input from terminal
			System.setIn(new ByteArrayInputStream(INPUT.getBytes()));
			in = new Scanner(System.in);
		}
		if (LOCAL && USE_FILE > 0) {
			String filename = String.format("in/cf%d.txt", USE_FILE);
			File inputFile = new File(filename);
			in = new Scanner(inputFile);
			out.printf("[%s]\n", filename);
			out.flush();
		}
		if (!LOCAL) {
			in = new Scanner(System.in);
		}

		long startTime = System.currentTimeMillis();
		testCases();
		if (LOCAL) {
			System.out.printf("[%dms]\n", System.currentTimeMillis()-startTime);
		}
		in.close();
	}

	static boolean LOCAL = System.getProperty("ONLINE_JUDGE") == null;
	Scanner in;
	PrintWriter out = new PrintWriter(System.out);

}




