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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4,avx,avx2,fma")
using namespace std;
const string nl = "\n";
using ll = int64_t;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using str = string;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <class T>
inline bool ckmin(T& a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool ckmax(T& a, T b) {
  return b > a ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void usaco(string x = "") {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  x = x;
  if ((int)x.size()) {
    freopen((x + ".in").c_str(), "r", stdin);
    freopen((x + ".out").c_str(), "w", stdout);
  }
}
str to_string(char c) { return str(1, c); }
str to_string(bool b) { return b ? "true" : "false"; }
str to_string(const char* second) { return (str)second; }
str to_string(str second) { return second; }
template <class A>
str to_string(complex<A> c) {
  stringstream ss;
  ss << c;
  return ss.str();
}
str to_string(vector<bool> v) {
  str res = "{";
  for (int i = 0; i < (int)v.size(); i++) res += char('0' + v[i]);
  res += "}";
  return res;
}
template <size_t SZ>
str to_string(bitset<SZ> b) {
  str res = "";
  for (int i = 0; i < b.size(); i++) res += char('0' + b[i]);
  return res;
}
template <class A, class B>
str to_string(pair<A, B> p);
template <class T>
str to_string(T v) {
  bool fst = 1;
  str res = "{";
  for (const auto& x : v) {
    if (!fst) res += ", ";
    fst = 0;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <class A, class B>
str to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
using node = int;
struct BIT {
  vector<node> bit;
  int n;
  void init(int x) {
    n = x + 5;
    bit.assign(n + 5, 0);
  }
  node sum(int r) {
    node ret = 0;
    for (; r; r -= r & -r) {
      ret += bit[r];
    }
    return ret;
  }
  node sum(int l, int r) { return sum(r) - sum(l - 1); }
  void add(int idx, node delta) {
    for (; idx < n; idx += idx & -idx) {
      bit[idx] += delta;
    }
  }
  node query(int l) { return sum(l); }
  void update(int l, int r, node v) {
    add(l, v);
    add(r + 1, -v);
  }
} bit;
const int mxN = 3e5 + 10;
int n, q, a[mxN], ans[mxN];
vpii queries[mxN];
signed main() {
  usaco("");
  cin >> n >> q;
  bit.init(n);
  for (int i = (1); i < (n + 1); i++) {
    cin >> a[i];
    a[i] = i - a[i];
  }
  for (int i = (0); i < (q); i++) {
    int l, r;
    cin >> l >> r;
    queries[n - r].push_back({1 + l, i});
  }
  for (int i = (1); i < (1 + n); i++) {
    if (a[i] >= 0) {
      int lo = 0, hi = i;
      while (lo < hi) {
        int mid = (lo + hi + 1) / 2;
        if (bit.query(mid) >= a[i]) {
          lo = mid;
        } else {
          hi = mid - 1;
        }
      }
      bit.update(1, hi, 1);
    }
    for (auto& w : queries[i]) {
      ans[w.second] = bit.query(w.first);
    }
  }
  for (int i = (0); i < (q); i++) {
    cout << ans[i] << nl;
  }
}
