#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n,m,a[N];
struct node
{
    int leftVal,rightVal;
    int incLeft, incRight;
    int fluctLeft, fluctRight;
    int len,best;
} st[4*N];
node Merge(node a, node b)
{
    int Best = max(a.best,b.best);
    // update inc subse
 //   cout << "GG " << b.incLeft << ' ' <<  b.fluctLeft << ' ' << a.fluctLeft << endl;
    int incR = b.incRight, incL = a.incLeft;
    if(a.rightVal < b.leftVal && b.incRight == b.len) {
        incR = a.incRight + b.len;
    }
    if(a.rightVal > b.leftVal && a.incLeft == a.len) {
        incL = b.incLeft + a.len;
    }
    // update best
    // case 1 converge
    if(a.rightVal > b.leftVal || a.rightVal < b.leftVal)
    {
        Best = max(Best,a.incRight+b.incLeft);
    }
    // case2 continue
    int fluctL = max(a.fluctLeft,a.incLeft), fluctR = (b.fluctRight,b.incRight);
    if(a.rightVal > b.leftVal || a.rightVal < b.leftVal)
    {
        if(b.len == b.incLeft) fluctR = max(fluctR,a.incRight + b.incLeft);
        if(a.len == a.incRight) fluctL = max(fluctL,a.incRight + b.incLeft);
        if(a.len == a.fluctLeft && a.rightVal > b.leftVal) fluctL = max(fluctL,a.fluctLeft + b.incLeft);
        if(b.len == b.fluctRight && a.rightVal < b.leftVal) fluctR = max(fluctL,b.fluctRight + a.incRight);
    }
    if(a.fluctRight != 0 && a.rightVal > b.leftVal) {
            Best = max(Best,a.fluctRight+b.incLeft);
            if(b.incLeft == b.len) fluctR = max(fluctR,a.fluctRight+b.incLeft);
    }
    if(b.fluctLeft != 0 && a.rightVal < b.leftVal) {
        Best = max(Best,b.fluctLeft+a.incRight);
        if(a.incRight == a.len) fluctL = max(fluctL,b.fluctLeft+a.incRight);
    }
    Best = max({Best,fluctR,fluctL});
    //
    return {a.leftVal,b.rightVal,
            incL,incR,
            fluctL,fluctR,
            a.len+b.len,Best};
}
void build(int id, int l, int r)
{
    if(l > r) return;
    if(l == r){
        st[id] = {a[l],a[l],1,1,0,0,1,0};
        return;
    }
    int mid = (l+r)/2;
    build(2*id,l,mid);
    build(2*id+1,mid+1,r);
    st[id] = Merge(st[2*id],st[2*id+1]);

}
void update(int id, int l, int r, int u)
{
    if(l > u || r < u) return;
    if(l == r)
    {
        st[id] = {a[l],a[l],1,1,0,0,1,0};
        return;
    }
    int mid = (l+r)/2;
    update(2*id,l,mid,u);
    update(2*id+1,mid+1,r,u);
    st[id] = Merge(st[2*id],st[2*id+1]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    build(1,1,n);
  //  cout << st[1].best << endl;
    for(int i = 1; i <= m; i++)
    {
        int x,y; cin >> x >> y;
        a[x] = y;
        update(1,1,n,x);
        cout << st[1].best <<'\n';
    }
}
