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.
#include <bits/stdc++.h>
using namespace std;
const int md = int(1e9) + 7;
const int inf = 0x3f3f3f3f;
const long long infl = 0x3f3f3f3f3f3f3f3f;
const int mx = 1 << 19;
int tree[2 * mx], flag[2 * mx];
void update(int i) {
  while (i /= 2) tree[i] = tree[i << 1] + tree[i << 1 | 1];
}
int query(int i, int l, int r, int u, int v) {
  if (u <= l && r <= v) return tree[i];
  int mid = (l + r) / 2;
  int lans = 0, rans = 0;
  if (u < mid) lans = query(i << 1, l, mid, u, v);
  if (mid < v) rans = query(i << 1 | 1, mid, r, u, v);
  return lans + rans;
}
int lower_bound_rtol(int pos, long long sm) {
  int i = mx + pos, l = pos, len = 1;
  long long tot = 0;
  while (l >= 0) {
    if (i & 1 && tree[i >> 1] + tot < sm)
      i >>= 1, l -= len, len <<= 1;
    else if (tree[i] + tot < sm)
      tot += tree[i--], l -= len;
    else if (len > 1)
      i = i << 1 | 1, len >>= 1, l += len;
    else
      break;
  }
  return l;
}
int lower_bound_rtol(long long sm) {
  int l = mx;
  long long tot = 0;
  for (int i = 1, len = mx; i && len; i = i << 1 | 1, len >>= 1) {
    if (tot + tree[i] < sm) {
      tot += tree[i];
      l -= len;
      i--;
    }
  }
  return l - 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
  }
  vector<tuple<int, int, int>> vq;
  for (int i = 0; i < (q); i++) {
    int l, r;
    cin >> l >> r;
    vq.push_back(make_tuple(n - r, l, i));
  }
  sort((vq).begin(), (vq).end());
  vector<int> vans(q);
  int it = 0;
  for (int i = 0; i < (n); i++) {
    int d = i + 1 - a[i];
    if (d >= 0) {
      int l = -1;
      l = lower_bound_rtol(i, d);
      if (l >= 0) {
        tree[mx + l]++;
        update(mx + l);
      }
    }
    while (it < q && get<0>(vq[it]) == i + 1) {
      int curr, curl, curi;
      tie(curr, curl, curi) = vq[it];
      int ans = 0;
      ans = query(1, 0, mx, curl, curr);
      vans[curi] = ans;
      it++;
    }
  }
  for (int i = 0; i < (q); i++) {
    cout << vans[i] << "\n";
  }
  return 0;
}
