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 kMaxN = 300001;
struct V {
  int s, mn, p, c;
} v[kMaxN * 4 + 1];
struct Q {
  int x, y, i, a;
  bool operator<(const Q &q) const { return x > q.x; }
} q[kMaxN];
int n, m, x;
void Add(int i, int s) {
  v[i].s += s;
  v[i].mn += s;
}
void PushDown(int i) {
  if (v[i].s) {
    Add(i * 2, v[i].s);
    Add(i * 2 + 1, v[i].s);
    v[i].s = 0;
  }
}
void PushUp(int i) {
  int c = !v[i * 2].p || (v[i * 2 + 1].p && v[i * 2 + 1].mn < v[i * 2].mn);
  v[i].p = v[i * 2 + c].p;
  v[i].mn = v[i * 2 + c].mn;
  v[i].c = v[i * 2].c + v[i * 2 + 1].c;
}
void Update(int i, int ml, int mr, int nl, int nr, int s) {
  if (nl > nr) {
    return;
  }
  if (ml == nl && mr == nr) {
    Add(i, s);
    if (ml == mr && !v[i].c) {
      v[i].p = ml;
    }
    return;
  }
  PushDown(i);
  int m = (ml + mr) / 2;
  Update(i * 2, ml, m, nl, min(m, nr), s);
  Update(i * 2 + 1, m + 1, mr, max(m + 1, nl), nr, s);
  PushUp(i);
}
void Get(int i, int ml, int mr, int t) {
  if (t < ml || t > mr) {
    return;
  }
  if (ml == mr) {
    v[i].c = 1;
    v[i].p = v[i].mn = 0;
    return;
  }
  PushDown(i);
  int m = (ml + mr) / 2;
  Get(i * 2, ml, m, t);
  Get(i * 2 + 1, m + 1, mr, t);
  PushUp(i);
}
int Calc(int i, int ml, int mr, int nl, int nr) {
  if (nl > nr) {
    return 0;
  }
  if (ml == nl && mr == nr) {
    return v[i].c;
  }
  PushDown(i);
  int m = (ml + mr) / 2;
  int r = Calc(i * 2, ml, m, nl, min(m, nr)) +
          Calc(i * 2 + 1, m + 1, mr, max(m + 1, nl), nr);
  PushUp(i);
  return r;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    x = i - x;
    if (x < 0) {
      x = n;
    }
    Update(1, 1, n, i, i, x + n);
  }
  for (int i = 1; i <= m; i++) {
    q[i].i = i;
    cin >> q[i].x >> q[i].y;
  }
  sort(q + 1, q + 1 + m);
  for (int i = 1, j = n; i <= m; i++) {
    for (; j > q[i].x; j--) {
      Update(1, 1, n, j, j, -n);
    }
    while (v[1].p && v[1].mn <= 0) {
      int p = v[1].p;
      Get(1, 1, n, p);
      Update(1, 1, n, p + 1, n, -1);
    }
    q[i].a = Calc(1, 1, n, 1, n - q[i].y);
  }
  sort(q + 1, q + 1 + m, [](Q a, Q b) { return a.i < b.i; });
  for (int i = 1; i <= m; i++) {
    cout << q[i].a << endl;
  }
  return 0;
}
