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;
inline long long gcd(long long a, long long b) {
  while (b != 0) {
    long long c = a % b;
    a = b;
    b = c;
  }
  return a < 0 ? -a : a;
}
inline long long lowbit(long long x) { return x & (-x); }
int head[2000010], Edge_Num;
struct Edge {
  int to, next;
  long long w;
} e[4000010];
inline void ade(int x, int y, long long w) {
  e[++Edge_Num] = {y, head[x], w};
  head[x] = Edge_Num;
}
inline void G_init(int n) {
  memset(head, 0, sizeof(int) * (n + 100));
  Edge_Num = 0;
}
int dir[8][2] = {{-1, 0},  {0, -1}, {1, 0},  {0, 1},
                 {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
const long double PI = 3.14159265358979323846;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
inline long long rd() {
  long long x = 0;
  bool f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return f ? x : -x;
}
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const int M = 1e6 + 10;
const int N = 1e6 + 10;
int n;
struct BIT {
  int pre[N], c[N];
  int c0 = 0;
  int n;
  void init(int Max) {
    n = Max;
    memset(c, 0, sizeof(int) * (n + 10));
    c0 = 0;
  }
  void build(int a[], int Max) {
    n = Max;
    for (int i = 1; i <= n; i++) {
      pre[i] = pre[i - 1] + a[i];
      c[i] = pre[i] - pre[i - lowbit(i)];
    }
    c0 = 0;
  }
  int get_sum(int x) {
    if (x < 0) return 0;
    int sum = 0;
    for (; x > 0; sum += c[x], x -= lowbit(x))
      ;
    return sum + c0;
  }
  void add(int x, int y) {
    if (x == 0) c0 += y;
    for (; x >= 1 && x <= n; c[x] += y, x += lowbit(x))
      ;
  }
} bit;
struct Query {
  int id;
  int l, r;
  bool friend operator<(const Query& m1, const Query& m2) {
    return m1.r < m2.r;
  }
} qq[N];
int a[N], lim[N], ans[N];
void solve() {
  n = rd();
  int q = rd();
  for (int i = 1; i <= n; i++) a[i] = i - (int)rd();
  for (int i = 1; i <= q; i++) {
    int x = rd(), y = rd();
    qq[i].l = x + 1, qq[i].r = n - y;
    qq[i].id = i;
  }
  bit.init(n);
  for (int i = 1; i <= n; i++) {
    if (a[i] < 0) a[i] = inf;
    int l = -1, r = i - 1;
    while (l < r) {
      int mid = (l + r + 1) >> 1;
      if (bit.get_sum(n) - bit.get_sum(mid - 1) >= a[i]) {
        l = mid;
      } else {
        r = mid - 1;
      }
    }
    lim[i] = l;
    bit.add(l, 1);
  }
  sort(qq + 1, qq + 1 + q);
  bit.init(n);
  for (int i = 1, pos = 1; i <= q; i++) {
    while (pos <= qq[i].r) {
      bit.add(lim[pos], 1);
      ++pos;
    }
    ans[qq[i].id] = bit.get_sum(n) - bit.get_sum(qq[i].l - 2);
  }
  for (int i = 1; i <= q; i++) {
    printf("%d\n", ans[i]);
  }
}
int main() {
  int _T = 1;
  while (_T--) solve();
}
