#include <bits/stdc++.h>
using namespace std;
const int maxn = 800009;
int c[maxn], h[maxn], x[maxn], ans[maxn], pre[maxn], suf[maxn];
int n, Q, m, p, LIS, vis[maxn], res[maxn];
pair<int, pair<int, int> > q[maxn];
int del() {
  int n = 1;
  for (int i = 2; i <= m; i++)
    if (x[i - 1] != x[i]) x[++n] = x[i];
  return n;
}
int search(int k) {
  int l = 1, r = m, mid;
  while (l < r) {
    mid = (l + r) >> 1;
    if (k <= x[mid])
      r = mid;
    else
      l = mid + 1;
  }
  return l;
}
void update(int x, int y) {
  for (; x <= m; x += ((x) & (-x))) c[x] = max(c[x], y);
}
int query(int x) {
  int res = 0;
  for (; x; x -= ((x) & (-x))) res = max(res, c[x]);
  return res;
}
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &h[i]);
    x[++m] = h[i];
  }
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d", &q[i].first, &q[i].second.first);
    x[++m] = q[i].second.first;
    q[i].second.second = i;
  }
  sort(x + 1, x + m + 1);
  m = del();
  for (int i = 1; i <= n; i++) h[i] = search(h[i]);
  for (int i = 1; i <= Q; i++) q[i].second.first = search(q[i].second.first);
  sort(q + 1, q + Q + 1);
  p = 1;
  for (int i = 1; i <= n; i++) {
    while (p <= Q && q[p].first == i) {
      ans[q[p].second.second] += query(q[p].second.first - 1) + 1;
      p++;
    }
    update(h[i], pre[i] = query(h[i] - 1) + 1);
    LIS = max(LIS, pre[i]);
  }
  memset(c, 0, sizeof c);
  p = Q;
  for (int i = n; i >= 1; i--) {
    while (1 <= p && q[p].first == i) {
      ans[q[p].second.second] += query(m - q[p].second.first);
      p--;
    }
    update(m - h[i] + 1, suf[i] = query(m - h[i]) + 1);
  }
  for (int i = 1; i <= n; i++)
    if (pre[i] + suf[i] == LIS + 1) vis[pre[i]]++;
  for (int i = 1; i <= Q; i++)
    ans[q[i].second.second] =
        max(ans[q[i].second.second],
            LIS - (pre[q[i].first] + suf[q[i].first] == LIS + 1 &&
                   vis[pre[q[i].first]] == 1));
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
  return 0;
}
