#include <bits/stdc++.h>

#ifndef This_is_Kunteynir
#define dbg(...)
#endif

#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi")

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define len(x) ((int)x.size())

using namespace std;
using ll = long long;
using ld = long double;
using i128 = __int128;

struct Node{
    int pr = 0, sf = 0, ans = 0;
    int prm = 0, sfm = 0;
    int flp = 0, flm = 0;

    Node() {}

    Node(int x) {
        if (x == 1) {
            pr = sf = flp = 1;
        }
        if (x == -1) {
            prm = sfm = flm = 1;
        }
    }

    Node operator+(const Node &other) const {
        Node rt;
        rt.ans = max(ans, other.ans);
        rt.ans = max(rt.ans, 2 * min(sf, other.prm));
        rt.flp = flp & other.flp;
        rt.flm = flm & other.flm;

        rt.pr = pr;
        if (flp) {
            rt.pr += other.pr;
        }
        rt.prm = prm;
        if (flm) {
            rt.prm += other.prm;
        }

        rt.sf = other.sf;
        if (other.flp) {
            rt.sf += sf;
        }
        rt.sfm = other.sfm;
        if (other.flm) {
            rt.sfm += sfm;
        }

        return rt;
    }
};

vector<Node> tree;
vector<int> w;

void build(int u, int l, int r) {
    if (r - l == 1) {
        tree[u] = Node(w[l]);
        return;
    }
    int m = (l + r) / 2;
    build(2 * u + 1, l, m);
    build(2 * u + 2, m, r);
    tree[u] = tree[2 * u + 1] + tree[2 * u + 2];
}

void upd(int u, int l, int r, int ind, int x) {
    if (r - l == 1) {
        tree[u] = Node(x);
        return;
    }
    int m = (l + r) / 2;
    if (ind < m) {
        upd(2 * u + 1, l, m, ind, x);
    } else {
        upd(2 * u + 2, m, r, ind, x);
    }
    tree[u] = tree[2 * u + 1] + tree[2 * u + 2];
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &h : a) cin >> h;
    if (n == 1) {
        int tt;
        cin >> tt;
        while (tt--) {
            cout << "1\n";
        }
        return;
    }
    w.resize(n - 1);
    tree.resize(4 * n - 4);
    for (int i = 0; i + 1 < n; ++i) {
        w[i] = a[i + 1] - a[i];
    }

    build(0, 0, n - 1);
    cout << tree[0].ans + 1 << '\n';

    int tt;
    cin >> tt;
    while (tt--) {
        int ind, x;
        cin >> ind >> x;
        --ind;
        a[ind] = x;
        if (ind != n - 1) {
            w[ind] = a[ind + 1] - a[ind];
            upd(0, 0, n - 1, ind, w[ind]);
        }
        if (ind > 0) {
            w[ind - 1] = a[ind] - a[ind - 1];
            upd(0, 0, n - 1, ind - 1, w[ind - 1]);
        }
        cout << tree[0].ans + 1 << '\n';
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _ = 1;
    // cin >> _;
    while (_--) {
        solve();
        cout << '\n';
    }
}
