#include <bits/stdc++.h>
using namespace std;
const int N = (int)4e5 + 4;
const int inf = (int)1e9 + 7;
const long double eps = 1e-7;
const int K = 21;
const int M = 1001;
int a[N], d[N], p_l[N], p_r[N];
struct query {
  int val, ind, len;
  query() { val = 0, ind = 0, len = 0; }
  ~query() {}
  query(int val, int ind) : val(val), ind(ind), len(0) {}
};
query queries[N];
int size;
int ans[N];
vector<query> g[N];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < q; ++i) {
    int ind, val;
    scanf("%d%d", &ind, &val);
    g[--ind].push_back(query(val, i));
  }
  d[0] = 0;
  for (int i = 1; i <= n; ++i) {
    d[i] = inf;
  }
  int k = 0;
  for (int i = 0; i < n; ++i) {
    int l, r;
    for (query &cur : g[i]) {
      l = 0, r = i;
      for (; r > l;) {
        int m = (l + r) / 2 + 1;
        if (d[m] < cur.val) {
          l = m;
        } else {
          r = m - 1;
        }
      }
      cur.len += l;
    }
    l = 0, r = i;
    for (; r > l;) {
      int m = (l + r) / 2 + 1;
      if (d[m] < a[i]) {
        l = m;
      } else {
        r = m - 1;
      }
    }
    d[l + 1] = min(d[l + 1], a[i]);
    p_l[i] = l;
    k = max(l + 1, k);
  }
  d[0] = inf;
  for (int i = 1; i <= n; ++i) {
    d[i] = 0;
  }
  for (int i = n - 1; i >= 0; --i) {
    int l, r;
    for (query &cur : g[i]) {
      l = 0, r = n - i - 1;
      for (; r > l;) {
        int m = (l + r) / 2 + 1;
        if (d[m] > cur.val) {
          l = m;
        } else {
          r = m - 1;
        }
      }
      cur.len += r;
    }
    l = 0, r = n - i - 1;
    for (; r > l;) {
      int m = (l + r) / 2 + 1;
      if (d[m] > a[i]) {
        l = m;
      } else {
        r = m - 1;
      }
    }
    d[l + 1] = max(d[l + 1], a[i]);
    p_r[i] = l;
  }
  map<pair<int, int>, int> mt;
  for (int i = 0; i < n; ++i) {
    ++mt[make_pair(p_l[i], p_r[i])];
  }
  for (int i = 0; i < n; ++i) {
    for (query &cur : g[i]) {
      if (cur.len == k) {
        ans[cur.ind] = k + 1;
      } else {
        if (p_l[i] + p_r[i] == k - 1 && mt[make_pair(p_l[i], p_r[i])] == 1 &&
            cur.len < k - 1) {
          ans[cur.ind] = k - 1;
        } else {
          ans[cur.ind] = k;
        }
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
