#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PII pair<int, int> using namespace std; const int N = 4e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ; int n, m, tot, h[N], hs[N], dp[][N], stk[N], cnt[N], LIS;
bool is[N]; struct ChairmanTree {
struct node {
int mx, l, r;
} a[N * ];
int tot, root[N];
void update(int p, int val, int l, int r, int &x, int y) {
x = ++tot; a[x] = a[y];
a[x].mx = max(a[x].mx, val);
if(l == r) return ;
int mid = l + r >> ;
if(p <= mid) update(p, val, l, mid, a[x].l, a[y].l);
else update(p, val, mid + , r, a[x].r, a[y].r);
}
int query(int L, int R, int l, int r, int x) {
if(hs[r] < L || hs[l] > R) return ;
if(hs[l] >= L && hs[r] <= R) return a[x].mx;
int ans = , mid = l + r >> ;
if(L <= hs[mid]) ans = query(L, R, l, mid, a[x].l);
if(R > hs[mid]) ans = max(ans, query(L, R, mid + , r, a[x].r));
return ans;
}
}ct[]; void getLIS() {
memset(stk, inf, sizeof(stk));
for(int i = ; i <= n; i++) {
dp[][i] = lower_bound(stk, stk + N, h[i]) - stk + ;
stk[dp[][i] - ] = h[i];
LIS = max(LIS, dp[][i]);
}
memset(stk, inf, sizeof(stk));
for(int i = n; i >= ; i--) {
dp[][i] = lower_bound(stk, stk + N, -h[i]) - stk + ;
stk[dp[][i] - ] = -h[i];
}
for(int i = ; i <= n; i++) {
if(dp[][i] + dp[][i] == LIS + ) {
is[i] = true;
cnt[dp[][i]]++;
}
}
} int main() {
scanf("%d%d", &n, &m);
for(int i = ; i <= n; i++) {
scanf("%d", &h[i]);
hs[++tot] = h[i];
}
sort(hs + , hs + + tot);
tot = unique(hs + , hs + + tot) - hs - ; for(int i = ; i <= n; i++)
h[i] = lower_bound(hs + , hs + + tot, h[i]) - hs;
getLIS(); for(int i = ; i <= n; i++)
ct[].update(h[i], dp[][i], , tot, ct[].root[i], ct[].root[i-]);
for(int i = n; i >= ; i--)
ct[].update(h[i], dp[][i], , tot, ct[].root[i], ct[].root[i+]); while(m--) {
int a, b;
scanf("%d%d", &a, &b);
int ans = is[a] ? LIS - : LIS;
ans = max(ans, ct[].query(, b - , , tot, ct[].root[a-])
+ ct[].query(b + , inf, , tot, ct[].root[a+]) + );
if(is[a] && cnt[dp[][a]] > ) {
ans = max(ans, LIS);
}
printf("%d\n", ans);
}
return ;
} /*
*/